Advertisement
Guest User

xpath

a guest
Jan 27th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. from lxml import html
  2. from lxml import etree
  3.  
  4. path = 'normalize-space(//div[@class="price"]/text())'
  5. url = 'http://www.bloomberg.com/quote/USDRUB:CUR'
  6.  
  7.  
  8. def get_urls_from_page(url):
  9.     doc = html.parse(url)
  10.     values = doc.getroot().xpath(path)
  11.     return values
  12.  
  13.  
  14. print(get_urls_from_page(url))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement