Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use Google News API to obtain the latest global news for your project, including a wide range of sources, headlines, URLs, and publication dates from the Google News platform.

NotificationsYou must be signed in to change notification settings

oxylabs/google-news-scraper

Repository files navigation

Oxylabs promo code

Free Google News Scraper

Prerequisites

To run this tool, you need to have Python 3.11 installed in your system.

Installation

Open up a terminal window, navigate to this repository and run this command:

make install

Getting the topic to scrape

This tool is used to scrape Google News articles based on the topic they're listed in.

First of all, open up Google News, and look through the topics listed in the top header of the webpage.

image

Click on a topic you wish to scrape.In this example we'll be using theBusiness topic.

Next, look at the URL in your browser and copy the string of characters that come after/topics/, that's your topic ID.

image

In the URL shown in the screenshot, the topic ID would beCAAqJggKIiBDQkFTRWdvSUwyMHZNRGx6TVdZU0FtVnVHZ0pWVXlnQVAB.

Save this value, you'll need it for scraping the articles.

Scraping

To scrape articles from your selected topic, run this command in your terminal:make scrape TOPIC_ID=<your_selected_topic_id>

With theBusiness topic ID selected before, the command should look like this:

make scrape TOPIC_ID=CAAqJggKIiBDQkFTRWdvSUwyMHZNRGx6TVdZU0FtVnVHZ0pWVXlnQVAB

After running the command, you should see this in your terminal:

image

When the tool has finished running, you should see a file namedarticles.csv in the directory you were running the tool.

If you open the generated CSV file, the data should look something like this:

image

Notes

In case the code doesn't work or your project is of bigger scale, please refer to the second part of the tutorial. There, we showcase how to scrape public data with Oxylabs Scraper API.

Oxylabs Google News API

You can get a7-day trial for Oxylabs Google News API and getfree 5K results. The tool will deliver a list ofsources, titles, URLs, and dates from published articles all over the Google News portal. This API returns real-time data and gives access to localized results, all while avoiding blocks.

After you claim your trial, using Google News API consists of three main steps:

  1. Create your API user via ourdashboard
  2. Send a request
  3. Retrieve the data in JSON or HTML

Request sample

In the example below, we use Google News API and make a request to collect search result pages for the search termadidas on thegoogle.nl domain:

import requestsfrom pprint import pprint# Structure payload.payload = {    'source': 'google_search',    'domain': 'nl',`    'query': 'adidas',    'parse': True,    'context': [        {'key': 'tbm', 'value': 'nws'},    ],}# Get response.response = requests.post(    'https://realtime.oxylabs.io/v1/queries',    auth=('USERNAME', 'PASSWORD'),    json=payload,)# Print prettified response to stdout.pprint(response.json())

To seerequest samples in other languages andparameter values along with theirdescriptions, please take a look at our extensiveGoogle News API documentation.

Read More Google Scraping Related Repositories:Google Sheets for Basic Web Scraping,How to Scrape Google Shopping Results,Google Play Scraper,How To Scrape Google Jobs,How to Scrape Google Scholar,How to Scrape Google Flights with Python,How To Scrape Google Images,Scrape Google Search Results,Scrape Google Trends

About

Use Google News API to obtain the latest global news for your project, including a wide range of sources, headlines, URLs, and publication dates from the Google News platform.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp