Created
January 18, 2012 10:20
-
-
Save kassoulet/1632317 to your computer and use it in GitHub Desktop.
Retreive package ratings from Ubuntu Software Center
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Retreive package ratings from Ubuntu Software Center | |
gautier at soundconverter.org | |
""" | |
from sys import argv, exit | |
from time import sleep | |
from requests import get | |
from envoy import run | |
if len(argv) < 2: | |
print('usage: reviews.py PACKAGE_NAME') | |
exit(1) | |
url = 'http://reviews.ubuntu.com/reviews/api/1.0/reviews/filter/en/%s/%s/any/%s/page/%d/' | |
package = argv[1] | |
distro, release = [x.lower() for x in run('lsb_release -sic').std_out.splitlines()] | |
i = 1 | |
while True: | |
r = get(url % (distro, release, package, i)) | |
content = r.content | |
i += 1 | |
if not content or len(content) <= 2: | |
break | |
print(content) | |
sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment