首页 新闻 会员 周边

python中爬出的数据怎么取不了文本啊 ,我想把照片上抓取的那些取文本的,有没有大佬会呀,找网上找好多天了都没有解决的办法

0
[待解决问题]

完整代码
import requests_cache as rc
from lxml import etree
import requests
from lxml import html
from html.parser import HTMLParser

rc.install_cache()
res=rc.CachedSession()
url="https://www.dy2018.com"
head={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36'
}
reponse=res.get(url,headers=head )
html=reponse.text
res.encoding='gb2312'
bs=etree.HTML(html)

reser=bs.xpath('//div[@class="co_content222"]/ul')[0:15]

print(reser)

d=bs.xpath('//*[@id="header"]/div/div[3]/div/div/div[2]/ul/li/a/@href')

print(d)

for i in d:
r= "https://www.dy2018.com" + format(i)
# print(r)
xml=res.get(r)
res.encoding='gb2312'

print(xml)

ads=etree.HTML(xml.text)

print(ads)

dd=ads.xpath('//*[@id="Zoom"]//br').text()
print(dd)

潇洒浪子猛回头的主页 潇洒浪子猛回头 | 菜鸟二级 | 园豆:218
提问于:2021-06-16 09:39
< >
分享
所有回答(1)
0

url对应的文本吗?
req = requests.get(url=url, headers=headers)
print(req)

人间春风意 | 园豆:2335 (老鸟四级) | 2021-06-16 09:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册