Guest User

Untitled

a guest
Feb 27th, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. #encoding: utf-8
  2. import StringIO, requests, time, operator
  3. from lxml import html
  4. from lxml import etree
  5.  
  6. r = requests.get("http://talisman.championat.com")
  7. page_source = r.text.encode('utf-8')
  8.  
  9. doc = html.parse(StringIO.StringIO(page_source))
  10. tmp = []
  11. for i in doc.xpath("/html/body/div/div/div/div[@class='voting__i _right']") + doc.xpath("/html/body/div/div/div/div[@class='voting__i ']"):
  12.     tmp.append((i.xpath("div[@class='voting__i__title']")[0].text_content().encode('utf8')[21:-37], int(i.xpath("div[@class='voting__i__votes']")[0].text_content())))
  13. for i in list(reversed(sorted(tmp, key=operator.itemgetter(1))))[:20]:
  14.     print i[0], i[1]
Advertisement
Add Comment
Please, Sign In to add comment