Я хочу получить связанный pdf из ключевых слов, используя bing API. Но я сталкиваюсь с некоторыми проблемами.
список ключевых слов:
"Hubble Space Telescope", "William Herschel", "Planetary Camera", "Milky Way"
Я следую этому коду:
import requests
subscription_key = "My Key"
assert subscription_key
search_url = "https://api.cognitive.microsoft.com/bing/v7.0/search"
search_term = ["Hubble Space Telescope", "William Herschel", "Planetary Camera", "Milky Way"]
result=[]
for i in range(len(search_term)):
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
params = {"q": search_term[i],"filetype":"pdf", "textDecorations":True, "textFormat":"HTML"}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
print search_results
result.append(search_results)
from IPython.display import HTML
for i in range(len(result)):
rows = "\n".join(["""<tr><td><a href=\"{0}\">{1}</a></td><td>{2}</td>
</tr>""".format(v["url"].encode("utf-8"),v["name"].encode("utf-8"),v["snippet"].encode("utf-8")) \
for v in result[i]["webPages"]["value"]])
HTML("<table>{0}</table>".format(rows))
print rows
Хотя я добавил тип файла: pdf в раздел params, но не получил pdf.
Может кто-нибудь подсказать мне, как поступить?