xpath的scrapy shell // * [contains(concat(“”,@class,“”),concat(“”,“ S3Uucc”,“”))]

时间:2019-12-12 03:37:57

标签: xpath scrapy

python,scrapy和xpath的新手。并为此奋斗。 我有一个xpath://*[contains(concat( " ", @class, " " ), concat( " ", "S3Uucc", " " ))] 我尝试了几个小时才能得到响应,但我什么也没得到。谁能帮助我创建有用的响应xpath字符串,该字符串可以返回我的数据?我尝试过:

>> response.xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "S3Uucc", " " ))]').getall() 
used get() but no result for the above

>> response.xpath ('//*[@class="S3Uucc"]').getall()

>> response.xpath('//span[@class="S3Uucc"]'.getall()
No result. 

实际网址来自Google https://www.google.com/search?q=siteurl%3Awww.google.co.nz+%22print+%7C+design%22+%22NZ%22+%22%40gmail.com%22&rlz=1C1CHWA_enNZ876NZ876&oq=site&aqs=chrome.1.69i57j69i59j69i61j69i65l3j69i61l2.6357j0j4&sourceid=chrome&ie=UTF-8

感谢帮助!

1 个答案:

答案 0 :(得分:1)

在firefox控制台中成功测试:

'//span[@class="S3Uucc"]/text()'