Home > other >  The crawler xpath parsing out the body, only downward path can only get an empty list
The crawler xpath parsing out the body, only downward path can only get an empty list

Time:03-09

Small white just began to learn the crawler, xpath parsing don't know why I can't use, a great god correct

Don't know why, the xpath can only access to the body tag


In the body tag parsing path followed by div tags, returned is an empty list


Try to add text behind the body tag () get the text, the returned is an empty list


The following is a code
 
The from LXML import etree
The import requests
If __name__=="__main__ ':
Url='https://sc.chinaz.com/jianli/biaoge.html'
Headers={
'the user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64. X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36 '
}
Data=https://bbs.csdn.net/topics/requests.get (url=url, headers=headers). The decode (' utf-8)
The tree=etree. HTML (' data ')
Page_list=tree. Xpath ('//body/text () ')
Print (page_list)


CodePudding user response:

No one? [face] monkey2:019 PNG [/face]
  • Related