def getPlaces(hmpage): query= "SELECT match.place.name FROM geo.placemaker WHERE documentURL = \"" + hmpage + "\" AND documentType=\"text/plain\" " placeurl= PUBLIC_API_URL + '?' + urllib.urlencode({ 'q': query, 'format': 'json', 'env': DATATABLES_URL }) placedata= rest.load(placeurl) places= [] try: for p in placedata["query"]["results"]["matches"]: #print p["match"]["place"]["name"] places.append(p["match"]["place"]["name"]) return places except: return places
def getAuthors(query): qurl= PUBLIC_API_URL + '?' + urllib.urlencode({ 'q': query, 'format': 'json', 'env': DATATABLES_URL }) qdata= rest.load(qurl) authors= [] for ele in qdata['query']['results']['p']: try: ele= ele.strip() ele= ele.split(",") if len(ele)> 1: lst= ele.pop(-1) lst= lst.split("and") ele.extend(lst) authors.extend(ele) except: continue f = file('Authors.db','w') pickle.dump(authors, f) f.close()
def create(name="", data=None, url=None, keep_standards_prefix=False): d = data if url is not None: d = rest.load(url) return WebTable(name, d=d, keep_standards_prefix=keep_standards_prefix)