-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathone.py
50 lines (37 loc) · 1.09 KB
/
one.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import time
import pandas as pd
import os
from bs4 import BeautifulSoup
import simplejson
import json
#import html2text
api_key = 'ndcq6rwvpenbagu7p9rkxpw6'
#currentDir = os.path.dirname(os.path.abspath(__file__))
#print currentDir
def API_test():
#company = unicode(company, errors='ignore')
company = "Minerva Surgical"
query = 'fun'
startGET = time.time()
url1 = 'http://api.crunchbase.com/v/1/company/'+company+'.js?api_key='+api_key
url2 = 'http://api.crunchbase.com/v/1/search.js?query='+query+'&page=1&api_key='+api_key
r = requests.get(url2)
if (r.status_code!= 200) or r.text is None:
return
#print r.text
try:
returned_json = json.loads(r.text, strict= False)
except ValueError:
return
#returned_json = r.json()
#print returned_json
if 'error' in returned_json:
return
#print returned_json["results"][1]
for i in range (1,10):
if "namespace" in returned_json["results"][i] \
and returned_json["results"][i]["namespace"] == "company":
print returned_json["results"][i]["name"]
if __name__ == '__main__':
API_test()