Skip to content

Instantly share code, notes, and snippets.

@ipl31
Created March 18, 2013 01:58
Show Gist options
  • Save ipl31/5184505 to your computer and use it in GitHub Desktop.
Save ipl31/5184505 to your computer and use it in GitHub Desktop.
get cik from ticker
import urllib2
import time
ticker = 'BAC'
string_match = 'rel="alternate"'
url = 'http://www.sec.gov/cgi-bin/browse-edgar?company=&match=&CIK=%s&owner=exclude&Find=Find+Companies&action=getcompany' % ticker
response = urllib2.urlopen(url)
for line in response:
if string_match in line:
for element in line.split(';'):
if 'CIK' in element:
cik = element.replace('&amp','')
print cik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment