Created
July 4, 2014 16:03
-
-
Save danjamker/b5b40e28c3e1ef2bac76 to your computer and use it in GitHub Desktop.
Gist for parsing the HTML file of acrynms from http://www.netlingo.com/acronyms.php into a CSV
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
__author__ = 'danielkershaw' | |
import urllib2 | |
import BeautifulSoup | |
import csv | |
def main(): | |
response = urllib2.urlopen('http://www.netlingo.com/acronyms.php') | |
html = response.read() | |
soup = BeautifulSoup.BeautifulSoup(html) | |
div = soup.find("div", {"class": "list_box3"}) | |
div = div.findAll("li") | |
abbrevlist = {} | |
for d in div: | |
abbrevlist[d.find('a').contents[0]] = d.contents[1] | |
f = csv.writer(open('dict.csv', 'wb')) | |
for key, value in abbrevlist.items(): | |
f.writerow([key, value]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment