2.requests是指从因特网上下载文件和网页。常用requests.get()函数下载一个网页
import requests
res=requests.get('http://www.gutenberg.org/cache/epub/1112/pg1112.txt')
type(res)
3查看京东源代码
4html文件是一个纯文本文件,带有.html文件扩展名
5.代码如下
import requests
r=requests.get("https://www.jd.com/?cu=true&utm_source=c.linktech.cn&utm_medium=tuiguang&utm_campaign=t_4_A100235089testjdid&utm_term=466f9db4934d489cb308f1c97305981c'")
html=r.text
f=open("C:\6wanDownload'',''w+")
f.write(html)
f.close()
print("successful")
6用beautifulsoup解析网页提取信息
4