SerpAPI - Search API

Let’s start by searching for Coffee on Google:

>>> import serpapi
>>> s = serpapi.search(q="Coffee", 
                       engine="google", 
                       location="Austin, Texas", 
                       hl="en", 
                       gl="us")
# s 是一个 SerpResults 对象,像是一个标准 dict,上面添加了一些便捷的功能

# 打印日志:
>>> s["organic\_results"][0]["link"]
'https://en.wikipedia.org/wiki/Coffee'

# 打印第一个结果,以 Python 的方式
>>> s["organic\_results"][0].get("title")
'Coffee - Wikipedia'


s 内容如下:

{
    "search\_metadata": {
        "id": "6602701cfe41d084fd3ed5da",
        "status": "Success",
        "json\_endpoint": "https://serpapi.com/searches/a15e1b92727f292c/6602701cfe41d084fd3ed5da.json",
        "created\_at": "2024-03-26 06:50:04 UTC",
        "processed\_at": "2024-03-26 06:50:04 UTC",
        "google\_url": "https://www.google.com/search?q=Coffee&oq=Coffee&uule=w+CAIQICIdQXVzdGluLFRYLFRleGFzLFVuaXRlZCBTdGF0ZXM&hl=en&gl=us&sourceid=chrome&ie=UTF-8",
        "raw\_html\_file": "https://serpapi.com/searches/a15e1b92727f292c/6602701cfe41d084fd3ed5da.html",
        "total\_time\_taken": 7.62
    },
    "search\_parameters": {
        "engine": "google",
        "q": "Coffee",
        "location\_requested": "Austin, Texas",
        "location\_used": "Austin,TX,Texas,United States",
        "google\_domain": "google.com",
        "hl": "en",
        "gl": "us",
        "device": "desktop"
    },
    "search\_information": {
        "query\_displayed": "Coffee",
        "total\_results": 5760000000,
        "time\_taken\_displayed": 0.37,
        "organic\_results\_state": "Results for exact spelling"
    },
    "local\_map": {
        "link": "https://www.google.com/search?sca\_esv=6cb148437a7a9a38&gl=us&hl=en&q=Coffee&npsic=0&rflfq=1&rldoc=1&rllag=31994604,-99807361,55029&tbm=lcl&sa=X&ved=2ahUKEwizk5Ccq5GFAxUDjokEHeceA94QtgN6BAglEAE",
        "image": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/2677b372a72544dbbc26036d5c7b09db.png",
        "gps\_coordinates": {
            "latitude": 31.994604,
            "longitude": -99.807361,
            "altitude": 55029
        }
    },
    "local\_results": {
        "places": [
            {
                "position": 1,
                "rating": 4.7,
                "reviews\_original": "(63)",
                "reviews": 63,
                "description": "Dine-in\u00b7Drive-through\u00b7No delivery",
                "place\_id": "16666839338430965111",
                "place\_id\_search": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google\_domain=google.com&hl=en&location=Austin%2C+Texas&ludocid=16666839338430965111&q=Coffee",
                "lsig": "AB86z5WD7smQJJZYj7Eh1KXWdsl2",
                "thumbnail": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/47f37fc32e9075402698b02afcfe658f15416b9c44ead714051999e4f099a16f03170b796c045734.jpeg",
                "service\_options": {
                    "dine\_in": true,
                    "drive\_through": true,
                    "no\_delivery": true
                },
                "title": "The Branch Coffeehouse",
                "type": "Coffee shop",
                "address": "Tuscola, TX",
                "hours": "Closed \u22c5 Opens 6 AM"
            },
            {
                "position": 2,
                "rating": 4.3,
               ...
            },
            {
                "position": 3,
                "rating": 4.8,
                ...
            }
        ],
        "more\_locations\_link": "https://www.google.com/search?sca\_esv=6cb148437a7a9a38&gl=us&hl=en&tbs=lf:1,lf\_ui:9&tbm=lcl&q=Coffee&rflfq=1&num=10&uule=w+CAIQICIdQXVzdGluLFRYLFRleGFzLFVuaXRlZCBTdGF0ZXM&sa=X&ved=2ahUKEwizk5Ccq5GFAxUDjokEHeceA94QjGp6BAgrEAE"
    },
    "
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值