grv
grv

Reputation: 1153

How to run an xpath over html page in python?

I think using lxml library in python can help, but not able to find out how to do this??

Upvotes: 0

Views: 678

Answers (1)

Jon Clements
Jon Clements

Reputation: 142156

A simple starting point...

import lxml.html
page = lxml.html.parse('http://www.google.com').getroot()
print page.xpath('//a/@href')

Upvotes: 4

Related Questions