Created
March 18, 2013 01:58
-
-
Save ipl31/5184505 to your computer and use it in GitHub Desktop.
get cik from ticker
This file contains hidden or 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
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('&','') | |
print cik |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment