Created
May 10, 2014 15:00
-
-
Save zguangyu/1fe91f8f9ac24db92a65 to your computer and use it in GitHub Desktop.
Generate igem Asia teams' links as html
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
from bs4 import BeautifulSoup | |
import urllib.request | |
import sys | |
if len(sys.argv) != 2: | |
print("Usage: "+sys.argv[0]+" <year>") | |
sys.exit(1) | |
response = urllib.request.urlopen("http://igem.org/Team_List?year="+sys.argv[1]) | |
html = BeautifulSoup(response.read().decode('utf-8')) | |
a = html.find('table', id="table_Teams_from_Asia").find_all('a') | |
doc = html.new_tag('ul') | |
for i in a: | |
del i['style'] | |
li = html.new_tag('li') | |
li.append(i) | |
doc.append(li) | |
with open(sys.argv[1]+".html", "w") as file: | |
file.write(doc.prettify()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank U :)