Last active
December 20, 2015 17:59
-
-
Save AntoineTurmel/6172544 to your computer and use it in GitHub Desktop.
Using python-beautifulsoup, parsing translate website for missing strings
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/python | |
import urllib | |
import sys | |
if len(sys.argv) == 1: | |
print "You must specify a locale" | |
else: | |
f = urllib.urlopen("http://translate.songbirdnest.com/languages/" + sys.argv[1]) | |
from BeautifulSoup import BeautifulSoup | |
html = f.read() | |
soup = BeautifulSoup(''.join(html)) | |
table = soup.find('table') | |
rows = table.findAll('tr') | |
for tr in rows: | |
cols = tr.findAll('td') | |
for td in cols: | |
text = td.find(text=True) | |
if text != None: | |
text = ''.join(td.find(text=True)) | |
print text+"", | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment