Home > other >  Python - Scrapy: ask god to help see if the path of the XPATH write wrong?
Python - Scrapy: ask god to help see if the path of the XPATH write wrong?

Time:10-31

Goal: to use Scrapy climb take off an author and content of jokes (with Scrapy. Other don't,)
https://www.qiushibaike.com/text/

I 10 lines of XPATH path estimation is write wrong, print it out, what also have no, also do not an error, a great god, please correct!
The other 14 lines, line 15 XPAHT path is also wrong?
 
The import scrapy


The class QiubaiSpider (scrapy. Spiders) :
Name='qiubai'
# allowed_domains=[' www.xxx.com ']
Start_urls=[' https://www.qiushibaike.com/text/']

Def parse (self, response) :
Div_list=response. Xpath ('//div/@/div ')
Print (div_list)
For div in div_list:
# authtor=div. Xpath ('/div/@/a [2]/h2/text () ') [0]. Extract ()
The author=div. Xpath ('/div [1] [2] a/h2/text () ') [0]. Extract ()
The content=div. Xpath ('/a [1]/div/span//text () '). The extract ()
Print (author, content)
Break

  • Related