Skip to content

Instantly share code, notes, and snippets.

@photonxp
Last active August 29, 2015 13:58
Show Gist options
  • Save photonxp/10015000 to your computer and use it in GitHub Desktop.
Save photonxp/10015000 to your computer and use it in GitHub Desktop.
CrucnBase api demo usage
#!/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