Skip to content

Instantly share code, notes, and snippets.

@walshie4
Created July 23, 2014 05:53
Show Gist options
  • Save walshie4/104532193d292d8ecf3a to your computer and use it in GitHub Desktop.
Save walshie4/104532193d292d8ecf3a to your computer and use it in GitHub Desktop.
Creates a list of countries names scraped from State.gov
#!/usr/bin/env python
#Written by: Adam Walsh
#Written on 7/23/14
#Gets a current list of countries from state.gov
from selenium import webdriver
sel = webdriver.Firefox()
sel.get("http://www.state.gov/misc/list/")
content = sel.find_element_by_id('tier3-landing-content-wide')
content = content.find_element_by_tag_name('table')
content = content.find_element_by_tag_name('div')
content = content.find_element_by_tag_name('div')
content = content.find_element_by_tag_name('div')
content = content.find_element_by_tag_name('div')
countries = []
for item in content.find_elements_by_tag_name('blockquote'):
for link in item.find_elements_by_tag_name('a'):
countries.append(link.text.encode('ascii','ignore'))
print countries
sel.close()
@walshie4
Copy link
Author

Note that this list does not include the US.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment