美文网首页
python 爬虫

python 爬虫

作者: 金泽夕 | 来源:发表于2019-12-09 14:08 被阅读0次

1.requests

import requests
url='http://baidu.com'
headers={
        "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36"
 }
params={}
req = requests.get(url,headers = headers)
content = req.content.decode('utf-8')

2.xpath

# 输出元素html
print(etree.tostring(a,encoding='utf-8').decode("utf-8"))

相关文章

网友评论

      本文标题:python 爬虫

      本文链接:https://www.haomeiwen.com/subject/ldvbgctx.html