scrapy and css

20 views
Skip to first unread message

d4v1d

unread,
Mar 22, 2014, 6:35:51 PM3/22/14
to scrapy...@googlegroups.com
hello
i would like to catch the value of an h2 in a web page
le h2 is like this : <h2 class="blabla"> tralala</h2>
i would like to catch tralala based on the class of the h2

I tried this 2 differents things but nothing work
item['h2'] =  sel.css('span.titre-fiche-nom-etab h2::text').extract()
item['h2'] =  sel.xpath('//h2/text()').css('span#blabla')

thanks in advance for your help
regards
Message has been deleted

Paul Tremberth

unread,
Mar 22, 2014, 6:42:28 PM3/22/14
to scrapy...@googlegroups.com
Try:
sel.css('h2.blabla::text')

Paul.

David LANGLADE

unread,
Mar 23, 2014, 8:47:30 AM3/23/14
to scrapy...@googlegroups.com
hello
thanks for your feedback
this work perfectly I just add a .exact() for optain the value
sel.css('h2.blabla::text').exact()
regards


--
You received this message because you are subscribed to a topic in the Google Groups "scrapy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scrapy-users/HAXUbYVDkOE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scrapy-users...@googlegroups.com.
To post to this group, send email to scrapy...@googlegroups.com.
Visit this group at http://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.



--
David LANGLADE
5 rue du patuel
42800 Saint martin la plaine
Tel : 06.49.42.38.85
Reply all
Reply to author
Forward
0 new messages