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"
},
"immersive\_products": [
{
"thumbnail": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/49e6224fb883d7093d9d5db8b6707fcdcb9bf962cec4743d996f7845da535981.webp",
"source": "Amazon.com, 10+",
"title": "Folgers Classic Roast Ground Coffee",
"price": "$4.49",
"extracted\_price": 4.49,
"immersive\_product\_page\_token": "eyJlaSI6IkluQU...lZSJ9",
"serpapi\_link": "https://serpapi.com/search.json?engine=google\_immersive\_product&page\_token=eyJlaS...UENfZmZlZSJ9"
},
{
"thumbnail": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/49e6224fb883d7093d9d5db8b6707fcd77fcca065cb1ab76d1fc85c40626c4b4.webp",
"source": "Black Rifle Coffee Company, 10+",
"title": "Black Rifle Coffee Company Murdered Out Coffee Roast",
"price": "$16.99",
"extracted\_price": 16.99,
"immersive\_product\_page\_token": "eyJlaSI6IkluQUNaclA2QklPY3B0UV....UFJPRF9QQ18xNTQ3NzA1NTU4Nzk2OTQ3MTc4NSIsInF1ZXJ5IjoiQ29mZmVlIn0=",
"serpapi\_link": "https://serpapi.com/search.json?engine=google\_immer...oiQ29mZmVlIn0%3D"
},
{
...
"title": "Bones Coffee Company New Flavors! Favorite Flavors Sample Pack 4 oz Pack of 5 Assorted Coffee Beans",
...
},
...
{
...
"title": "Starbucks Breakfast Blend Medium Roast Ground Coffee",
...
}
],
"related\_questions": [
{
"question": "Is coffee actually healthy for you?",
"snippet": "Hu said that moderate coffee intake\u2014about 2\u20135 cups a day\u2014is linked to a lower likelihood of type 2 diabetes, heart disease, liver and endometrial cancers, Parkinson's disease, and depression. It's even possible that people who drink coffee can reduce their risk of early death.",
"title": "Is coffee good or bad for your health? | News - hsph.harvard.edu",
"link": "https://www.hsph.harvard.edu/news/hsph-in-the-news/is-coffee-good-or-bad-for-your-health/#:~:text=Hu%20said%20that%20moderate%20coffee,their%20risk%20of%20early%20death.",
"displayed\_link": "https://www.hsph.harvard.edu \u203a news \u203a hsph-in-the-news",
"source\_logo": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/b460e89a15194171da0396937f5d7133523eb116b317ef2548aa4c977ab879e3.png",
"next\_page\_token": "eyJvbnMiOiIx...XzIifQ==",
"serpapi\_link": "https://serpapi.com/search.json?device=desktop&engine=..."
},
...
{
"question": "What are the 4 types of coffee?",
"snippet": "Learn about the four most popular types of coffee beans\u2014Arabica, Robusta, Excelsa and Liberica\u2014and when to use them.",
"title": "4 Types of Coffee Beans: How to Choose - KitchenAid",
...
}
],
"organic\_results": [
{
"position": 1,
"title": "Coffee",
"link": "https://en.wikipedia.org/wiki/Coffee",
"redirect\_link": "https://www.google.comhttps://en.wikipedia.org/wiki/Coffee",
"displayed\_link": "https://en.wikipedia.org \u203a wiki \u203a Coffee",
"thumbnail": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/19875953fd2763176ecb268a71b09fd91b6fe1da2d76a8e70422cfe845dba055.jpeg",
"favicon": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/19875953fd2763176ecb268a71b09fd980eab7533207994f46f9cbdee41bc698.png",
"snippet": "Coffee is a beverage brewed from roasted coffee beans. Darkly colored, bitter, and slightly acidic, coffee has a stimulating effect on humans, primarily due ...",
"snippet\_highlighted\_words": [
"Coffee",
"coffee",
"coffee"
],
"sitelinks": {
"inline": [
{
"title": "History",
"link": "https://en.wikipedia.org/wiki/History\_of\_coffee"
},
{
"title": "Coffee bean",
"link": "https://en.wikipedia.org/wiki/Coffee\_bean"
},
{
"title": "Coffee production",
"link": "https://en.wikipedia.org/wiki/Coffee\_production"
},
{
"title": "Coffee preparation",
"link": "https://en.wikipedia.org/wiki/Coffee\_preparation"
}
]
},
"source": "Wikipedia"
},
...
{
"position": 6,
"title": "Counter Culture Coffee",
...
"snippet\_highlighted\_words": [
"Coffee",
"coffee",
"coffee",
"coffee"
],
"sitelinks": {
"inline": [
{
"title": "Our Coffees",
"link": "https://counterculturecoffee.com/collections/coffee"
},
...
{
"title": "Subscriptions",
"link": "https://counterculturecoffee.com/pages/on-going-subscription"
}
]
},
"rich\_snippet": {
"top": {
"detected\_extensions": {
"free\_day\_delivery": 1
},
"extensions": [
"Free 1\u20134 day delivery"
]
}
},
"source": "Counter Culture Coffee"
},
{
"position": 7,
"title": "Coffee | The Nutrition Source - hsph.harvard.edu",
...
},
{
"position": 8,
"title": "Blanchard's Coffee Roasting Company",
...
"sitelinks": {
"inline": [
{
"title": "Products",
"link": "https://blanchardscoffee.com/collections/all"
},
{
"title": "Decent Instant Coffee",
"link": "https://blanchardscoffee.com/products/decent"
},
{
"title": "Blanchard's Cafe Pickup",
"link": "https://pickup.blanchardscoffee.com/"
},
{
"title": "Shop",
"link": "https://blanchardscoffee.com/pages/shop"
}
]
},
"rich\_snippet": {
"top": {
"detected\_extensions": {
"price": 14,
"currency": "$ to $",
"unknown": 5
},
"extensions": [
"$14 to $15",
"\u200e 5",
"day delivery"
]
}
},
"source": "Blanchard's Coffee"
},
{
"position": 9,
"title": "The Coffee Bean & Tea Leaf | CBTL",
"link": "https://www.coffeebean.com/",
"redirect\_link": "https://www.google.comhttps://www.coffeebean.com/",
"displayed\_link": "https://www.coffeebean.com",
"favicon": "https://serpapi.com/searches/6602701cfe41d084fd3ed5da/images/19875953fd2763176ecb268a71b09fd9f88be5e04c633b3b580c37b1b81751ac.png",
"snippet": "Born and brewed in Southern California since 1963, The Coffee Bean & Tea Leaf\u00ae is passionate about connecting loyal customers with carefully handcrafted ...",
"snippet\_highlighted\_words": [
"Coffee"
],
"source": "The Coffee Bean & Tea Leaf"
}
],
"related\_searches": [
{
"block\_position": 1,
"query": "Coffee shops near Texas",
"image": "https://lh5.googleusercontent.com/p/AF1QipOYChzmH\_DA-1Yz3mF8lQyEcinfGtJzaiUBxyUP=w40-h40-n-k-no"
},
{
"block\_position": 2,
"query": "Great coffee shop near Texas",
"image": "https://lh5.googleusercontent.com/p/AF1QipOYChzmH\_DA-1Yz3mF8lQyEcinfGtJzaiUBxyUP=w40-h40-n-k-no"
},
...
{
"block\_position": 1,
"query": "coffee powder",
...
}
],
"refine\_this\_search": [
{
"query": "Whole Bean",
"link": "https://www.google.com/search?sca\_esv=6cb148437a7a9a38&gl=us&hl=en&q=whole+bean+coffee&sa=X&ved=2ahUKEwizk5Ccq5GFAxUDjokEHeceA94Qs9oBKAB6BAguEAE",
"serpapi\_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google\_domain=google.com&hl=en&location=Austin%2C+Texas&q=whole+bean+coffee",
"thumbnail": "https://encrypted-tbn2.gstatic.com/shopping?q=tbn:ANd9GcTJVcQZ1jGbu7SLjXBxneWc\_xYUvdxhPAI1Gflp9AMbK4w7HS5fw3ItzDKnAx5qEle9SIbzx4FE9CZVnBoJDcN1jdTfbWEM50gozzPkGxbTQJ8236a419jb"
},
...
{
"query": "Bag",
...
},
{
"query": "Box",
...
}
],
"pagination": {
"current": 1,
"next": "https://www.google.com/search?q=Coffee&oq=Coffee&hl=en&gl=us&start=10&sourceid=chrome&ie=UTF-8",
"other\_pages": {
"2": "https://www.google.com/search?q=Coffee&oq=Coffee&hl=en&gl=us&start=10&sourceid=chrome&ie=UTF-8",
...
"5": "https://www.google.com/search?q=Coffee&oq=Coffee&hl=en&gl=us&start=40&sourceid=chrome&ie=UTF-8"
}
},
"serpapi\_pagination": {
"current": 1,
"next\_link": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google\_domain=google.com&hl=en&location=Austin%2C+Texas&q=Coffee&start=10",
"next": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google\_domain=google.com&hl=en&location=Austin%2C+Texas&q=Coffee&start=10",
"other\_pages": {
"2": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google\_domain=google.com&hl=en&location=Austin%2C+Texas&q=Coffee&start=10",
...
"5": "https://serpapi.com/search.json?device=desktop&engine=google&gl=us&google\_domain=google.com&hl=en&location=Austin%2C+Texas&q=Coffee&start=40"
}
}
}
The SerpApi.com API Documentation contains a list of all the possible parameters that can be passed to the API.
Basic Examples in Python
Search Bing
import os
import serpapi
client = serpapi.Client(api_key=os.getenv("API\_KEY"))
results = client.search({
'engine': 'bing',
'q': 'coffee',
})
- API Documentation: serpapi.com/bing-search-api
Search Baidu
results = client.search({
'engine': 'baidu',
'q': 'coffee',
})
- API Documentation: serpapi.com/baidu-search-api
Search Yahoo
results = client.search({
'engine': 'yahoo',
'p': 'coffee',
})
- API Documentation: serpapi.com/yahoo-search-api
Search YouTube
results = client.search({
'engine': 'youtube',
'search\_query': 'coffee',
})
- API Documentation: serpapi.com/youtube-search-api
Search Walmart
results = client.search({
'engine': 'walmart',
'query': 'coffee',
})
- API Documentation: serpapi.com/walmart-search-api
Search eBay
results = client.search({
'engine': 'ebay',
'\_nkw': 'coffee',
})
- API Documentation: serpapi.com/ebay-search-api
Search Naver
results = client.search({
'engine': 'naver',
'query': 'coffee',
})
- API Documentation: serpapi.com/naver-search-api
Search Home Depot
results = client.search({
'engine': 'home\_depot',
'q': 'table',
})
- API Documentation: serpapi.com/home-depot-search-api
Search Apple App Store
results = client.search({
'engine': 'apple\_app\_store',
'term': 'coffee',
})
- API Documentation: serpapi.com/apple-app-store
Search DuckDuckGo
results = client.search({
'engine': 'duckduckgo',
'q': 'coffee',
})
- API Documentation: serpapi.com/duckduckgo-search-api
Search Google
results = client.search({
'engine': 'google',
'q': 'coffee',
'engine': 'google',
})
- API Documentation: serpapi.com/search-api
Search Google Scholar
results = client.search({
'engine': 'google\_scholar',
'q': 'coffee',
})
- API Documentation: serpapi.com/google-scholar-api
Search Google Autocomplete
results = client.search({
'engine': 'google\_autocomplete',
'q': 'coffee',
})
- API Documentation: serpapi.com/google-autocomplete-api
Search Google Product
results = client.search({
'engine': 'google\_product',
'q': 'coffee',
'product\_id': '4887235756540435899',
**自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**
**深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**
**因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**
![img](https://img-blog.csdnimg.cn/img_convert/f5df90209fe3f59d3778c9424e43610c.png)
![img](https://img-blog.csdnimg.cn/img_convert/aa84106ca8e1da691c8e0b733bfe6b69.png)
![img](https://img-blog.csdnimg.cn/img_convert/46506ae54be168b93cf63939786134ca.png)
![img](https://img-blog.csdnimg.cn/img_convert/252731a671c1fb70aad5355a2c5eeff0.png)
![img](https://img-blog.csdnimg.cn/img_convert/6c361282296f86381401c05e862fe4e9.png)
![img](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!**
**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**
**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注Python)**
提升又不知道该从何学起的朋友,同时减轻大家的负担。**
[外链图片转存中...(img-FDxznUe3-1712551045342)]
[外链图片转存中...(img-mS80rkEc-1712551045343)]
![img](https://img-blog.csdnimg.cn/img_convert/46506ae54be168b93cf63939786134ca.png)
![img](https://img-blog.csdnimg.cn/img_convert/252731a671c1fb70aad5355a2c5eeff0.png)
![img](https://img-blog.csdnimg.cn/img_convert/6c361282296f86381401c05e862fe4e9.png)
![img](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!**
**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**
**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注Python)**
<img src="https://img-community.csdnimg.cn/images/fd6ebf0d450a4dbea7428752dc7ffd34.jpg" alt="img" style="zoom:50%;" />