通过设置ua模拟浏览器

import requests
from lxml import etree

url='https://ie.icoa.cn/'
head={'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'}
res=requests.get(url,headers=head)   #通过设置 headers模拟浏览器
res.encoding='utf-8'
root=etree.HTML(res.text)
ua=root.xpath('//table[@class="zebra"]/tr/td/i/text()')
print(ua)

猜你喜欢

转载自www.cnblogs.com/tiankong-blue/p/11594888.html