我正在寻找一种方法来检索搜索词的相关关键字,并且正在考虑使用 delicious API 来实现这个目标:
我发现一些网站为此目的使用 delicious API,我引用的 stackoverflow 问题中也提到了这些网站:
How to retrieve delicious related tags 例如:http://hublog.hubmed.org/archives/001049.html
我浏览了漂亮的 API,但没有找到任何可以给我想要的结果的函数。
delicious.com 是否仍提供此功能?如果可以,我如何将它与 Python 一起使用?
我试图用这个 Python 包装器类检索一些数据: https://github.com/mudge/python-delicious但它似乎也缺乏检索相关关键字的功能。
最佳答案
这是使用 Python 查找相关关键字的简单方法:
import requests
import xmltodict
import json
import re
KEYWORD = 'best icecream'
res = requests.get('https://google.com/complete/search?output=toolbar&gl=eg&q={}'.format({re.sub("\s", "_", KEYWORD)}))
obj = xmltodict.parse(res.text)
json = json.dumps(obj)
print(json)
结果预览:
{
"toplevel":{
"CompleteSuggestion":[
{
"suggestion":{
"@data":"best ice cream scoop"
}
},
{
"suggestion":{
"@data":"best ice cream places"
}
},
{
"suggestion":{
"@data":"best ice cream places near me"
}
},
{
"suggestion":{
"@data":"best ice cream in india"
}
},
{
"suggestion":{
"@data":"best ice cream in rome"
}
},
{
"suggestion":{
"@data":"best keto ice cream"
}
},
{
"suggestion":{
"@data":"best vanilla ice cream"
}
},
{
"suggestion":{
"@data":"best ice cream"
}
},
{
"suggestion":{
"@data":"best ice cream maker"
}
},
{
"suggestion":{
"@data":"best ice cream brands"
}
}
]
}
}
关于python - 如何访问 Delicious API 以检索 Google 相关关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19520619/