The CNN Scraper is an advanced tool designed to extract and organize news content from the Cable News Network (CNN) website. This powerful scraper offers an efficient method to collect up-to-the-minute news articles, headlines, and associated information, providing valuable insights for various industries and applications.
Data Point | Description | Example |
---|---|---|
Article ID | Unique identifier for the article | https://www.cnn.com/2024/04/06/tech/teachers-grading-ai/index.html |
URL | Web address of the article | https://www.cnn.com/2024/04/06/tech/teachers-grading-ai/index.html |
Author | Writer or contributor of the article | Sam***ha ***phy********* |
Headline | Title of the news article | Teachers are using AI to grade essays. But some experts are raising ethical concerns |
Topics | Categories or subjects covered | business, tech |
Publication Date | When the article was first published | 2024-04-06T18:00:26.456Z |
Last Updated | When the article was last modified | 2024-04-06T18:00:26.456Z |
Content | Full text of the news article | [Full article text] |
Images | Associated images with descriptions and URLs | [Image data] |
Related Articles | Links to related news stories | [If available] |
Keyword | Main topic or focus of the article | AI Model Governance |
The CNN Scraper is a valuable asset for various sectors, including:
The CNN Scraper API allows you to extract news articles and information from CNN.com. This powerful tool enables developers to integrate CNN news content into their applications, conduct news analysis, or monitor current events and trends.
To use the CNN Scraper API, you'll need to authenticate your requests using your API key. The API provides two endpoints for retrieving news information:
Include your API key in the request headers:
Authorization: Bearer YOUR_API_KEY
The request body should be a JSON object with the following structure:
// For news endpoint
{
"url": "https://edition.cnn.com/year/month/day/category/article-title/index.html"
}
// For news-by-search endpoint
{
"url": "https://edition.cnn.com/search?q=your+search+query"
}
Please note that usage is subject to rate limiting. Refer to your plan details for specific limits.
Here's an example of the data you can expect to receive:
[
{
"input": {
"url": "https://edition.cnn.com/2024/07/08/politics/biden-fate-political-career/index.html",
"keyword": ""
},
"id": "https://www.cnn.com/2024/07/08/politics/biden-fate-political-career/index.html",
"url": "https://www.cnn.com/2024/07/08/politics/biden-fate-political-career/index.html",
"author": "Stephen Collinson",
"headline": "Biden's fate is on the line in the most critical days of his 50-year political career",
"topics": [
"politics"
],
"publication_date": "2024-07-08T04:00:42.411Z",
"updated_last": "2024-07-08T13:44:50.596Z",
"content": "The high-stakes week ahead is critical to whether President Joe Biden's defiance will save his reelection bid or whether Democrats who question his capacity to serve a second term will succeed in pressuring him to step aside...",
"videos": [
{
"video_description": "CNN's Dana Bash shares what her sources are telling her about a call between top Democrats and their leadership where they discussed President Joe Biden campaign.",
"video_url": "https://vod-media-aka.warnermediacdn.com/cnn/v2/clips/2024-07/1584224-57604da819d94239868766993393adcc/mp4/democrat-leadership-call-biden-dana-bash-digvid-1584224-1920x1080_8000k.mp4"
}
],
"images": [
{
"image_url": "https://media.cnn.com/api/v1/images/stellar/prod/gettyimages-2159959397.jpg?c=original",
"image_description": "President Joe Biden speaks during a barbecue for active-duty military families at the White House on July 4, 2024."
}
],
"related_articles": [
{
"article_title": "Biden's ABC interview does nothing to quell the existential crisis around his campaign",
"article_url": "https://www.cnn.com/2024/07/06/politics/biden-abc-interview-analysis"
},
{
"article_title": "Inside a despondent White House: Aides gripped by unease as Biden's political future remains uncertain",
"article_url": "https://www.cnn.com/2024/07/08/politics/white-house-biden-despondent"
},
{
"article_title": "Several top House Democrats say Biden should step aside during leadership call",
"article_url": "https://www.cnn.com/2024/07/07/politics/house-democrats-biden-out"
},
{
"article_title": "Harris puts focus on beating Trump, not concerns over Biden, as she tries to appeal to Black voters",
"article_url": "https://www.cnn.com/2024/07/06/politics/harris-black-voters-essence-festival"
}
],
"keyword": null
}
]
import requests
import json
# Your API Key
api_key = 'YOUR_API_KEY'
# API Endpoint for news by URL
url = 'https://taskagi.net/api/news/cnn-scraper/news'
# Headers
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
# Request Body
data = {
'url': 'https://edition.cnn.com/2024/07/08/politics/biden-fate-political-career/index.html'
}
# Send POST request
response = requests.post(url, headers=headers, json=data)
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
news_info = response.json()
# Print the news information
print(json.dumps(news_info, indent=2))
else:
print(f"Error: {response.status_code}")
print(response.text)
# API Endpoint for news by search
url = 'https://taskagi.net/api/news/cnn-scraper/news-by-search'
# Request Body for search
data = {
'url': 'https://edition.cnn.com/search?q=climate+change'
}
# Send POST request
response = requests.post(url, headers=headers, json=data)
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
search_results = response.json()
# Print the search results
print(json.dumps(search_results, indent=2))
else:
print(f"Error: {response.status_code}")
print(response.text)