We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第四章 信息校验与反爬虫 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 选择器在重定向上有原理差异?
html.xpath('//h1/text()')
The text was updated successfully, but these errors were encountered:
No branches or pull requests
第四章 信息校验与反爬虫 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 选择器在重定向上有原理差异?The text was updated successfully, but these errors were encountered: