Hi, I am experimenting with web scraping using lxml. I have played a little with BeautifulSoup in the past and scrapy recently. I am recoding something I did with scrapy with lxml but encounter a problem I am not sure how to iron out. With scrapy, hxs is an xpath selector which has a select and re method types = hxs.select('.//a[@href]/@href').re(r'type=([A-Z]*)') Which will return a list of the matches in href. How would I do the same thing with lxml? types = doc.xpath('.//a[@href]/@href') ... Thanks a lot, -- EuGeNe -- I lend my books on COlivri http://www.colivri.org/user/eugene, do you?
Eugene Van den Bulke, 02.07.2010 10:49:
I am experimenting with web scraping using lxml.
I have played a little with BeautifulSoup in the past and scrapy recently.
I am recoding something I did with scrapy with lxml but encounter a problem I am not sure how to iron out.
With scrapy, hxs is an xpath selector which has a select and re method
types = hxs.select('.//a[@href]/@href').re(r'type=([A-Z]*)')
Which will return a list of the matches in href.
How would I do the same thing with lxml?
types = doc.xpath('.//a[@href]/@href') ...
http://lmgtfy.com/?q=lxml+regular+expressions&l=1 ;-) Stefan
participants (2)
-
Eugene Van den Bulke -
Stefan Behnel