Try to search your question here, if you can't find : Ask Any Question Now ?

How to select specific elements in span from @class xpath response

HomeCategory: stackoverflowHow to select specific elements in span from @class xpath response
Avatargaurav asked 1 week ago

I am learning to use xpath in scrapy, but the html I am trying to scrape is quite complicated.

I have tried selecting some things with html, css and xpath but I have reached this:

response.xpath('//span[starts-with(@class,"Animal-")]').getall()

which returns:

[u'<span class="Animal-1" title="Dogs" legs="4" tail="true"></span>', u'<span class="Animal-7" title="Birds" beak="true"></span>', u'<span class="Animal-24" title="Elephants"></span>']

I used a separate script to just return the contents of the title element to get me going, but I know that this is a hacky solution.
How can I return only the following:

Dogs
Birds
Elephants
1 Answers
Best Answer
AvatarAmit answered 1 week ago
Your Answer

3 + 4 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com