Skip to content

Instantly share code, notes, and snippets.

@danjamker
Created July 4, 2014 16:03
Show Gist options
  • Save danjamker/b5b40e28c3e1ef2bac76 to your computer and use it in GitHub Desktop.
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
__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