python - 如何访问 Delicious API 以检索 Google 相关关键字

标签 python delicious-api

我正在寻找一种方法来检索搜索词的相关关键字,并且正在考虑使用 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/

相关文章:

python - 在函数中创建不同的对象

python - 在python中将字典转换为数据框

python - 使用按需 HOT Insight 集群从 Azure 数据工厂 V2 访问数据湖

javascript - 在网站中嵌入美味的 JSON-Feed

c# - 使用 C# 的美味 .NET API

python - python 中的 time.mktime 时区是否免费?

api - 不再有 Delicious API feeds.delicious.com 了吗?

c# - 使用 RestSharp 进行美妙的 API 调用

python - 在后台运行特定的 Django 脚本