daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Jul 4th, 2012 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re, operator
  2. from bs4 import BeautifulSoup
  3.  
  4. h = BeautifulSoup(open('diskuze.html').read())
  5. divs = h.find_all("div", "ds_hlavicka")
  6. names = {}
  7.  
  8. for div in divs:
  9.         div = str(div)
  10.         m = re.search('(\d\d):\d\d(.*?)<b', div, re.DOTALL)
  11.         n = m.group(2).strip()
  12.         if n[0] == '<':
  13.                 n = re.search('>(.*?)<', n).group(1)
  14.         names[n] = names.get(n, 0)
  15.         names[n] += 1
  16.        
  17.  
  18. names = sorted(names.items(), key=operator.itemgetter(1))
  19. names.reverse()
  20.  
  21. for n in names:
  22.         print(n[0] + ": " + str(n[1]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top