Last active
September 21, 2017 13:25
-
-
Save joelthelion/0a5e60a907fdbdabe3a133f0e04b6dff to your computer and use it in GitHub Desktop.
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/env python3 | |
from itertools import islice | |
import re | |
import requests | |
from bs4 import BeautifulSoup | |
if __name__ == '__main__': | |
stat_soup = BeautifulSoup(requests.get("https://stats.lineageos.org/").content, "lxml") | |
code_soup = BeautifulSoup(requests.get("https://wiki.lineageos.org/devices/").content, "lxml") | |
names = {} | |
for table in code_soup.find_all("table", class_="device"): | |
for row in table.find_all("tr"): | |
try: | |
item = row.td.a | |
common_name = item.text.strip() | |
code = item["href"].split("/")[-1] | |
names[code] = common_name | |
except AttributeError as e: | |
pass | |
for row in stat_soup.find(id="top-devices").find_all(class_="leaderboard-row"): | |
model = row.span.a.text | |
popularity = int(row.find_all("span",recursive=False)[1].text) | |
if popularity < 50: break | |
name = names.get(model, "UNKNOWN") | |
print(f"{name:50} : {popularity} ({model})") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment