-
Notifications
You must be signed in to change notification settings - Fork 184
Open
Description
第四章 信息校验与反爬虫 postman 示例
cookie 反爬虫
`import requests
from lxml import etree
url = 'http://www.porters.vip/verify/cookie/content.html'
resp = requests.get(url)
if resp.status_code == 200:
html = etree.HTML(resp.text)
res = html.cssselect('.page-header h1') #①
print(res)
else:
print('This request is fail.')`
① 处 使用的是css选择器,需要指定cookie才有内容返回,但我没有加cookie,使用xpath(改为 html.xpath('//h1/text()') ) 后就爬取到了主题,为什么?难道 xpath 与 css 选择器在重定向上有原理差异?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels