猫史档案馆


【Python作品分享】新的作品【教程贴】

用户:固执的蓝雀8sy1固执的蓝雀8sy1查看:0 回复:0 评论:0 创建时间:2021-10-29T18:18:24


【作品展示】

center_image

 

【作品介绍】

这是我的作品

 

【作品源代码】

import requests


# 获取网页源代码

def getHtml(url):

    # 发送请求,r:response
    res = requests.get(url)
    # 判断是否请求成功
    if (res.status_code == 200):
        # 设置编码
        res.encoding = res.apparent_encoding
        # 获取html文本数据,t:text
        return res.text
    else:
        print('请求失败')
        return ''

# 目标网址
url = 'https://show.ybccode.com/show/index.html'
html = getHtml(url)
# 输出网页源代码
print(html)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页