PageRenderTime 39ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/count-downloads.py

http://semanticvectors.googlecode.com/
Python | 32 lines | 21 code | 7 blank | 4 comment | 5 complexity | ba2ba84627e8e6296fa4b1dfdd3f62a8 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # Handy script for counting the number of times each release of
  2. # semantic vectors has been downloaded.
  3. #
  4. # Run using 'python count-downloads.py'.
  5. import urllib
  6. import re
  7. site_url = "http://code.google.com/p/semanticvectors/downloads/list"
  8. site = urllib.urlopen(site_url)
  9. site_html = site.readlines()
  10. td_match = re.compile("<td class=\"vt col_4\"")
  11. sv_match = re.compile("detail\?name=(semanticvectors[^\&]*)\&")
  12. count_match = re.compile("^\s*(\d+)\s*$")
  13. total_count = 0
  14. for i in range(len(site_html)):
  15. if td_match.search(site_html[i]):
  16. if sv_match.search(site_html[i]):
  17. download_name = sv_match.search(site_html[i]).group(1)
  18. while True:
  19. if count_match.search(site_html[i+1]):
  20. count = count_match.search(site_html[i+1]).group(1)
  21. total_count += int(count)
  22. print count, "\t", download_name
  23. break
  24. i += 1
  25. print "Total:", total_count