Skip to content

Real-time flight data from Google Flights using a free scraper or Bright Data’s high-volume Google Flights Scraper API for reliable, scalable data collection.

Notifications You must be signed in to change notification settings

luminati-io/google-flights-api

Repository files navigation

Google Flights Scraper

Promo

This repository provides two ways to extract flight data from Google Flights:

  1. Free Google Flights Scraper: Ideal for small-scale extraction
  2. Google Flights Scraper API: Designed for high-volume, real-time data extraction with unlimited requests. Part of Bright Data's SERP Scraping API.

Table of Contents

  1. Free Scraper
  2. Google Flights Scraper API
  3. Additional Parameters
  4. Support & Resources

Free Scraper

A quick and simple scraper for limited data extraction from Google Flights.

google-flights-scraper

Setup Requirements

pip install playwright
playwright install chromium

New to web scraping? Explore our Beginner's Guide to Web Scraping with Python

Quick Start

  1. Open google-flights-scraper.py
  2. Update the following variable:
    • url: Paste the Google Flights URL (usually contains tfs).
  3. Run the script.

💡 Pro Tip: Set HEADLESS = False to minimize detection by Google's anti-scraping measures.

Sample Output

{
  "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"
}

👉 View complete output sample

Limitations

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. 👇

Google Flights Scraper API

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.

Key Features

  • 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

Prerequisites

  1. Create a Bright Data account (new users receive a $5 credit).
  2. Generate your API key.
  3. Follow our step-by-step guide to configure the SERP API and set up your credentials.

Direct API Access

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'.")

Native Proxy-Based Access

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.

Additional Parameters

Fine-tune your Google Flights data extraction with these optional parameters.

Localization Parameters

bright-data-google-flights-api-localization

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"

Currency Parameter

bright-data-google-flights-api-currency

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"

Support & Resources

About

Real-time flight data from Google Flights using a free scraper or Bright Data’s high-volume Google Flights Scraper API for reliable, scalable data collection.

Topics

Resources

Stars

Watchers

Forks

Languages