Building a travel guide can feel like a huge task as it needs quite a bit of research and likely involves making tons of Google searches for each different place. From finding the best hotels and best local restaurants to figuring out what the best tourist spots are in a particular location - there's a mountain of information out there scattered across the web.
It's possible to automate all of this, and build a location specific travel guide by scraping real time search engine results using any programming language of your choice. In this blog post, I'll demonstrate how to use SerpApi's APIs in combination with Python to collect and structure travel related information such as top attractions, local restaurants, hotels, and pictures for each of them in a simple easy-to-read guide.
Why Use SerpApi
SerpApi manages the intricacies of scraping and returns structured JSON results, which allows you to save time and effort. We take care of proxies and any CAPTCHAs that might be encountered, so that you don't have to worry about your searches being blocked.
We also do all the work to maintain our parsers. This is important, as Google and other search engines are constantly experimenting with new layouts, new elements, and other changes. By taking care of this for you on our side, we eliminate a lot of time and complexity from your workflow.
What We Will Accomplish
We'll build a simple travel guide for a specific city. For this blog post, we'll select San Francisco, California and extract lots of data from SerpApi including:
- Top destinations
- Local restaurant listings
- Local hotels
SerpApi offers multiple APIs to gather travel related information. We're going to use Google Maps API, Google Hotels API, and Google Local Places API to gather all of this information.
We'll also need to decide how to display the information. In this blog post, I'm going to create a Markdown file with all the information in the end.
You can find the entire code file and generated output here.
Getting Started
To begin scraping data, first, create a free account on serpapi.com. You'll receive one hundred free search credits each month to explore the API.
- Get your SerpApi API Key from this page.
- [Optional but Recommended] Set your API key in an environment variable, instead of directly pasting it in the code. Refer here to understand more about using environment variables. For this tutorial, I have saved the API key in an environment variable named "SERPAPI_API_KEY" in my .env file.
- Next, on your local computer, you need to install the
google-search-results
Python library:pip install google-search-results
You can use this library to scrape search results from any of SerpApi's APIs.
More About Our Python Libraries
We have two separate Python libraries serpapi
and google-search-results
, and both work perfectly fine. However, serpapi
is a new one, and all the examples you can find on our website are from the old one google-search-results
. If you'd like to use our Python library with all the examples from our website, you should install the google-search-results
module instead of serpapi
.
For this blog post, I am using google-search-results
because all of our documentation references this one.
You may encounter issues if you have both libraries installed at the same time. If you have the old library installed and want to proceed with using our new library, please follow these steps:
- Uninstall
google-search-results
module from your environment. - Make sure that neither
serpapi
norgoogle-search-results
are installed at that stage. - Install
serpapi
module, for example with the following command if you're usingpip
:pip install serpapi
Scraping The Data
Now we can head to a code editor, and begin writing code to scrape search results in a new Python file. Let's extract the details in parts. To being, create a new python file: create_travel_guide.py
. We will add code to this in the various sections below.
Scraping Top Destinations
To learn more about destinations of interest in a location, let's try a search query like: "Points of Interest in <location>" using our Google Maps API and extract some details about the place in our playground:

You can visualize the response by heading to our playground, and searching with the relevant parameter values. We will use Google Maps API to get the top attractions in the city in our Python script.
from serpapi import GoogleSearch
import os, json
from dotenv import load_dotenv
load_dotenv()
api_key = os.environ["SERPAPI_API_KEY"]
location = "San Francisco, California"
# Google Maps API request to get points of interest in the location
params = {
"api_key": api_key,
"engine": "google_maps",
"q": f'Points of Interest in {location}',
"hl": "en",
"gl": "us"
}
search = GoogleSearch(params)
local_results = search.get_dict()["local_results"]
sight_results = []
for result in local_results:
sight_details = {}
sight_details["title"] = result["title"]
sight_details["thumbnail"] = result["thumbnail"]
sight_results.append(sight_details)
This will give you all the titles and images of the popular sights in that city. We'll use this later while creating our guide.
Listing Local Restaurants
To list local restaurants in a city, you can query our Google Local API, or still continue using our Google Maps API. Here I'll give an example using our Google Local API. I'm using the query "Best restaurants in San Francisco, California". We can view the results in playground first to confirm the fields we want to extract:

Let's write the code now to get the top restaurants in a location. Here I'm creating a list of top restaurants and recording each restaurant's title, rating, type, address and thumbnail because these are the details I would like to include in my guide. You can add or remove any of these as per your requirements.
# Google Local API request to get top restaurants in the location
params = {
"api_key": api_key,
"engine": "google_local",
"q": f'Best restaurants in {location}',
"hl": "en",
"gl": "us"
}
search = GoogleSearch(params)
local_results = search.get_dict()["local_results"]
restaurants_results = []
for result in local_results:
# Extracting the name and image URL of each point of interest
restaurants_result = {}
restaurants_result["title"] = result["title"]
restaurants_result["rating"] = result["rating"]
restaurants_result["type"] = result["type"]
restaurants_result["address"] = result["address"]
restaurants_result["picture"] = result["thumbnail"]
restaurants_results.append(restaurants_result)
Now we have collected major details about the top restaurants in the city. We'll use this later while creating our guide.
Finding Local Hotels
To find local hotels in a city, you can query our Google Hotels API, or still continue using our Google Maps API. Here I'll give an example using our Google Hotels API. I'm using the query "Best hotels in San Francisco, California" along with the hotel_class
filter to get only 4 or 5 star hotels in the area. You can modify this as you need for your use case.
We can view the results in playground first to confirm the fields we want to extract:

Let's write code now to get the best hotels in a location. Here I'm creating a list of the top hotels and recording each hotel's name, description, link, picture, price, rating, and thumbnail because these are the details I would like to include in my guide. You can add or remove any of these as per your requirements.
# Google Hotels API request to get best hotels in the location
params = {
"api_key": api_key,
"engine": "google_hotels",
"q": f'Best Hotels in {location}',
"hl": "en",
"gl": "us",
"check_in_date": "2025-12-12",
"check_out_date": "2025-12-15",
"currency": "USD",
"hotel_class": "4,5"
}
search = GoogleSearch(params)
properties = search.get_dict()["properties"]
hotel_results = []
for result in properties:
# Extracting the name and image URL of each point of interest
hotel_details = {}
hotel_details["name"] = result["name"]
hotel_details["link"] = result["link"]
hotel_details["rate_per_night"] = result["rate_per_night"]["lowest"]
hotel_details["thumbnail"] = result["images"][0]["thumbnail"]
hotel_details["rating"] = result["overall_rating"]
hotel_results.append(hotel_details)
Now we have collected metadata about the best 4 and 5 star hotels in the city. We'll use this later while creating our guide.
Building the Travel Guide
To build the guide with the data we have collected above, I'm going to use markdown. I'll keep the layout simple, but you can modify as needed for your use case. I created this simple layout for the travel guide:

To fill in information into this template, I have created a simple script in the same python file where we have been extracting information. This will create a new file called "generated_sanfrancisco_guide.md" in your current directory with all the information in the format above, and you can view it using any markdown reader. Let's add this code to our python file:
# Writing the data to a markdown file
with open("generated_sanfrancisco_guide.md", "w") as f:
f.write("# San Francisco Travel Guide\n\n")
f.write("## Top Sights\n")
for sight in sight_results:
f.write(f"### {sight["title"]}\n")
f.write(f"![{sight["title"]}]({sight["thumbnail"]})\n\n")
f.write("## Top Restaurants\n")
for restaraunt in restaurant_results:
f.write(f"### {restaraunt["title"]}\n")
f.write(f"![{restaraunt["title"]}]({restaraunt["thumbnail"]})\n\n")
f.write(f"#### Cuisine: {restaraunt["type"]}\n")
f.write(f"#### Rating: {restaraunt["rating"]}/5\n")
f.write(f"#### Address: {restaraunt["address"]}\n")
f.write("## Top Hotels\n")
for hotel in hotel_results:
f.write(f"### {hotel["name"]}\n")
f.write(f"![{hotel["name"]}]({hotel["thumbnail"]})\n\n")
f.write(f"#### Link: {hotel["link"]}\n")
f.write(f"#### Rate per night: {hotel["rate_per_night"]}\n")
f.write(f"#### Rating: {hotel["rating"]}/5\n")
print("Travel Guide Created Successfully!")
Let's run the code now to generate this markdown file. You can run this by typing python create_travel_guide.py
in terminal.
Visualizing Results
Let's view the resulting Travel Guide file together:
You can add more details about each location as needed. You can also scrape other things like activities in the area, or top things to do with children in the same python file as well by modifying/adding another a request to a relevant API. You can view a full list our APIs here.
Conclusion
We've covered how to build a travel guide for a city using SerpApi's Python library and a variety of our APIs. You can find the entire code file and generated output here.
I hope you found this tutorial helpful. If you have any questions, don't hesitate to reach out to me at sonika@serpapi.com.
Relevant Links
- Playground
- API Documentation pages
- Plans and Pricing page
- Python Integration Guide
- SerpApi Use Cases - Build a Travel App using SerpApi
Related Posts

