鱼C论坛

 找回密码
 立即注册
查看: 3335|回复: 0

[萌新报道] 爬虫

[复制链接]
发表于 2020-9-2 15:34:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import requests
  2. from lxml import etree

  3. url = 'http://www.xbiquge.la/modules/article/waps.php'



  4. data = {
  5.     'searchkey':'无敌真寂寞'
  6. }

  7. headers = {
  8.     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18363'
  9. }

  10. reponse = requests.post(url=url,headers=headers,data=data)
  11. reponse.encoding = reponse.apparent_encoding
  12. html = reponse.text
  13. # print(html)
  14. tree = etree.HTML(html)

  15. content = tree.xpath('//table[@class="grid"]/tbody//text()')

  16. print(content)
复制代码

我爬这个网页的时候xpath里不加tbody信息都能打印出来,一加tbody就什么都没了,有大佬能给看一下吗
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-28 05:13

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表