raullenchai / LiterHub

http://www.literhub.com/
1 stars 0 forks source link

Support BING search #3

Open raullenchai opened 12 years ago

raullenchai commented 12 years ago

Bing is really not goot at return the pdf url:

word = 'Hardware Implementations of Multi-output Welch-Gong Ciphers' url = 'http://api.bing.net/json.aspx?AppId=8B0C8B80A1045CC62F695048C980F50E1734168A&Version=2.2&Market=en-US&Query=' +urllib.quote(word)+ '&Sources=web+spell&Web.Count=20&JsonType=raw'

print url

request = urllib2.Request(url, None, {'Referer': 'www.literhub.com'}) response = simplejson.load(urllib2.urlopen(request))

for x in response["SearchResponse"]["Web"]["Results"]: if x["Description"].lower().find(word.lower()) >=0: print x["DisplayUrl"]

print word.lower()

{"SearchResponse":{"Version":"2.2","Query":{"SearchTerms":"Hardware Implementations of Multi-output Welch-Gong Ciphers"},"Web":{"Total":3410,"Offset":0,"Results":[{"Title":"Publications | Communications Security Lab, University of Waterloo","Description":"C. Lam, M. Aagaard and G. Gong, Hardware Implementations of Multi-output Welch-Gong Ciphers, Technical Report, University of Waterloo, CACR 2011-01.","Url":"http:\/\/www.comsec.uwaterloo.ca\/publications.html","CacheUrl":"http:\/\/cc.bingj.com\/cache.aspx?q=hardware+implementations+of+%22multi+output%22+%22welch+gong%22+ciphers&d=4778095726756324&w=27552ed5,c9ae019d","DisplayUrl":"www.comsec.uwaterloo.ca\/publications.html","DateTime":"2012-02-02T21:36:00Z"}]}}}