Skip to content

Instantly share code, notes, and snippets.

@gamingflexer
Created August 28, 2022 14:41
Show Gist options
  • Save gamingflexer/3e84ebc02d375b844fc5b78020fe3736 to your computer and use it in GitHub Desktop.
Save gamingflexer/3e84ebc02d375b844fc5b78020fe3736 to your computer and use it in GitHub Desktop.
Scrape Top Headlines For a Particular Hashtags
import requests,json
API_KEY = ""
def headline_script():
url = "https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/search/NewsSearchAPI"
querystring = {"q":"TOPIC NEEDED","pageNumber":"1","pageSize":"10","autoCorrect":"true","fromPublishedDate":"null","toPublishedDate":"null"}
headers = {
"X-RapidAPI-Key": API_KEY,
"X-RapidAPI-Host": "contextualwebsearch-websearch-v1.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
return json.loads(response.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment