Created
April 13, 2017 21:09
-
-
Save nishnik/6ac7bb64e15d8d18d860c1564753b021 to your computer and use it in GitHub Desktop.
Scrapes scores from MetaKGP's "Contribution Scores" page
This file contains hidden or 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
from bs4 import BeautifulSoup | |
import requests | |
data_list = [] | |
link = "https://wiki.metakgp.org/w/Special:ContributionScores" | |
response = requests.get(link) | |
html = response.content | |
source = BeautifulSoup(html, "lxml") | |
trs = source.findAll("tr") | |
run = False | |
for tr in trs: | |
try: | |
print (len(tr)) | |
if len(tr) == 6: | |
if (not run): | |
run = True | |
continue | |
else: | |
break | |
if (not(len(tr) == 7)): | |
continue | |
td = tr.findAll("td")[4] | |
print (td) | |
data_list.append([td.a["href"], td.a.text]) | |
except Exception as e: | |
print (e, tr) | |
print (data_list[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment