pyquery标签选择

获取了所有的img标签(css选择器,你也可以换成不同的class和id)

 

 1 import requests
 2 import re
 3 from pyquery import PyQuery as pq
 4 headers={
 5     "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
 6     "Accept-Encoding": "gzip, deflate",
 7     "Accept-Language": "zh-CN,zh;q=0.9",
 8     "Upgrade-Insecure-Requests": "1",
 9     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36"
10   }
11 response=requests.get('https://www.zhihu.com/question/35239964/answer/66644148',headers=headers,timeout=9)
12 doc=pq(response.content)
13 #css选择器
14 a=doc('img')#<class 'pyquery.pyquery.PyQuery'>
15 print(a)
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2021-12-22
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案