from lxml import etree
import requests
url='https://tieba.baidu.com/f/search/res?isnew=1&kw=&qw=%C8%EB%C8%BA&un=&rn=10&sd=&ed=&sm=1&only_thread=1&pn=0'
response=requests.get(url)
content=response.text
print(content)
html=etree.HTML(content)
pics=html.xpath('//img[@class="p_pic"]/@original')
print(pics)
for pic in pics:
print(pic)
我這樣去采集匹配 結果是空的,但是我吧content列印出來然后放a.html里面用這種方式可以正常匹配出來是什么原因啊,真是懵了
from lxml import etree
f=open('./a.html','rb')
content=f.read()
html=etree.HTML(content)
pics=html.xpath('//img[@class="p_pic"]/@original')
for pic in pics:
print(pic)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/274229.html
上一篇:神經網路量化
下一篇:提問:陣列模糊匹配分類
