|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import requests
- from lxml import etree
- url = 'http://www.xbiquge.la/modules/article/waps.php'
- data = {
- 'searchkey':'无敌真寂寞'
- }
- headers = {
- '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'
- }
- reponse = requests.post(url=url,headers=headers,data=data)
- reponse.encoding = reponse.apparent_encoding
- html = reponse.text
- # print(html)
- tree = etree.HTML(html)
- content = tree.xpath('//table[@class="grid"]/tbody//text()')
- print(content)
复制代码
我爬这个网页的时候xpath里不加tbody信息都能打印出来,一加tbody就什么都没了,有大佬能给看一下吗 |
|