环境:python3.6
工具:PyCharm
目标:爬取一个HTML页面(先不考虑JavaScript,CSS等)
import requests
req = requests.get('http://chuanyuezhe.yetianzi.com')
#解决编码问题
req.encoding = 'utf-8'
file = open('/tmp/xiaoshuo.html', 'w')
file.write(req.text)
file.close()
环境:python3.6
工具:PyCharm
目标:爬取一个HTML页面(先不考虑JavaScript,CSS等)
import requests
req = requests.get('http://chuanyuezhe.yetianzi.com')
#解决编码问题
req.encoding = 'utf-8'
file = open('/tmp/xiaoshuo.html', 'w')
file.write(req.text)
file.close()
本文标题:python爬虫(1)-helloworld
本文链接:https://www.haomeiwen.com/subject/ufadbxtx.html
网友评论