Last active
August 29, 2015 13:58
-
-
Save photonxp/10015000 to your computer and use it in GitHub Desktop.
CrucnBase api demo usage
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
#!/usr/bin/python | |
# simplistic demo | |
# refer to the api doc of the website for more api interfaces and usage | |
import urllib | |
developer_key = "something_you_should_change_here" | |
REQUEST_URL = "http://api.crunchbase.com/v/1/company/facebook.js?api_key=%s" % developer_key | |
print "CHECK REQUEST URL:", REQUEST_URL | |
readed = urllib.urlopen(REQUEST_URL) | |
def get_n_lines(n): | |
"get the first n lines of readed content as a list by urllib" | |
lines = [] # to store the first n lines | |
c = 1 # counter for increasement | |
for line in readed: | |
if c <= n: | |
lines.append(line) | |
c += 1 | |
else: | |
break | |
return lines | |
lines = get_n_lines(14) | |
print "".join(lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment