有趣的技术
思路:
效果:会在桌面生成一个html文件,打开即为百度首页。
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| import requests
url = "http://www.baidu.com/"
response = requests.get(url)
content = response.content.decode("utf-8")
print(content) with open("baibu.html", "w", encoding="utf-8") as fp: fp.write(content)
|