This repository provides two ways to extract flight data from Google Flights:
- Free Google Flights Scraper: Ideal for small-scale extraction
- Google Flights Scraper API: Designed for high-volume, real-time data extraction with unlimited requests. Part of Bright Data's SERP Scraping API.
A quick and simple scraper for limited data extraction from Google Flights.
- Python 3.9+
- Playwright for browser automation
pip install playwright
playwright install chromium
New to web scraping? Explore our Beginner's Guide to Web Scraping with Python
- Open google-flights-scraper.py
- Update the following variable:
url
: Paste the Google Flights URL (usually containstfs
).
- Run the script.
💡 Pro Tip: Set HEADLESS = False
to minimize detection by Google's anti-scraping measures.
{
"airline": "Emirates",
"departure_time": "4:15 AM",
"arrival_time": "2:00 PM",
"duration": "22 hr 15 min",
"stops": "1 stop in DXB",
"price": "$1,139",
"co2_emissions": "1,092 kg CO2e",
"emissions_variation": "+6% emissions"
}
The Free Scraper has several constraints:
- High risk of IP blocking
- Limited request volume
- Frequent CAPTCHAs
- Unreliable for production use
For robust, scalable scraping without these limitations, consider Bright Data's dedicated API below. 👇
Bright Data's Google Flights Scraper API is integrated into the SERP Scraping API and leverages our extensive proxy network to extract real-time flight data—including prices, schedules, and airline details—at scale, without CAPTCHAs or IP blocks.
- Global Accuracy: Tailored results for specific locations
- Pay-Per-Success: Only pay for successful requests
- Real-Time Data: Get up-to-date flights data in seconds
- Unlimited Scalability: Handle high-volume scraping effortlessly
- Cost-Efficient: Eliminates the need for costly infrastructure
- Reliable Performance: Built-in anti-blocking technology
- 24/7 Expert Support: Assistance whenever required
- Create a Bright Data account (new users receive a $5 credit).
- Generate your API key.
- Follow our step-by-step guide to configure the SERP API and set up your credentials.
Make a direct request to the API endpoint.
cURL Example:
curl https://api.brightdata.com/request \
-H "Content-Type: application/json" \
-H "Authorization: Bearer API_TOKEN" \
-d '{
"zone": "ZONE_NAME",
"url": "https://www.google.com/travel/flights/search?tfs=CBwQAhojEgoyMDI1LTA0LTAxagcIARIDREVMcgwIAxIIL20vMDRqcGxAAUgBcAGCAQsI____________AZgBAg",
"format": "raw"
}'
Python Example:
import requests
url = "https://api.brightdata.com/request"
headers = {"Content-Type": "application/json", "Authorization": "Bearer API_TOKEN"}
payload = {
"zone": "ZONE_NAME",
"url": "https://www.google.com/travel/flights/search?tfs=CBwQAhojEgoyMDI1LTA0LTAxagcIARIDREVMcgwIAxIIL20vMDRqcGxAAUgBcAGCAQsI____________AZgBAg",
"format": "raw",
}
response = requests.post(url, headers=headers, json=payload)
with open("google-flights-data.html", "w", encoding="utf-8") as file:
file.write(response.text)
print("HTML response saved to 'google-flights-data.html'.")
Alternatively, use Bright Data's proxy routing method.
cURL Example:
curl -i \
--proxy brd.superproxy.io:33335 \
--proxy-user "brd-customer-<customer-id>-zone-<zone-name>:<zone-password>" \
-k \
"https://www.google.com/travel/flights/search?tfs=CBwQAhojEgoyMDI1LTA0LTAxagcIARIDREVMcgwIAxIIL20vMDRqcGxAAUgBcAGCAQsI____________AZgBAg"
Python Example:
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
host = "brd.superproxy.io"
port = 33335
username = "brd-customer-<customer-id>-zone-<zone-name>"
password = "<zone-password>"
proxy_url = f"http://{username}:{password}@{host}:{port}"
proxies = {"http": proxy_url, "https": proxy_url}
url = "https://www.google.com/travel/flights/search?tfs=CBwQAhojEgoyMDI1LTA0LTAxagcIARIDREVMcgwIAxIIL20vMDRqcGxAAUgBcAGCAQsI____________AZgBAg"
response = requests.get(url, proxies=proxies, verify=False)
with open("google-flights-data.html", "w", encoding="utf-8") as file:
file.write(response.text)
print("Response saved to 'google-flights-data.html'.")
👉 View the full HTML output.
Note: For production use, load Bright Data's SSL certificate as per the SSL Certificate Guide.
Fine-tune your Google Flights data extraction with these optional parameters.
Customize search results based on location and language:
Parameter | Description | Example |
---|---|---|
gl | Two-letter country code | gl=us (United States) |
hl | Two-letter language code | hl=en (English) |
Example: Search for flights from Paris to London in French:
curl --proxy brd.superproxy.io:33335 --proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
"https://www.google.com/travel/flights/search?tfs=CBwQAhojEgoyMDI1LTA0LTAxagcIARIDQ0RHcgwIAxIIL20vMDRqcGxAAUgBcAGCAQsI____________AZgBAg&hl=fr&gl=fr"
Define the currency for returned prices using the curr
parameter.
Example: Return prices in USD.
curl --proxy brd.superproxy.io:33335 --proxy-user brd-customer-<customer-id>-zone-<zone-name>:<zone-password> \
"https://www.google.com/travel/flights/search?tfs=CBwQAhojEgoyMDI1LTA0LTAxagcIARIDQ0RHcgwIAxIIL20vMDRqcGxAAUgBcAGCAQsI____________AZgBAg&hl=fr&gl=fr&curr=USD"
- Docs: SERP API Documentation
- Related APIs: Web Unlocker API, SERP API, Google Search API, Google News Scraper, Google Trends API, Google Reviews API, Google Hotels API
- Google Scraping Tutorials:
- Use Cases:
- Additional Reading: Best SERP APIs
- Contact Support: [email protected]