'Scraping newspaper article titles with google news
Below is my code for scraping news about domestic violence. This code worked perfectly the first time I used it. But back then I covered only 2-3 months period, I re-tried it with a wider time frame, it returns an empty string. Why might that be and how can I solve it?
from GoogleNews import GoogleNews
from newspaper import Article
import pandas as pd
googlenews = GoogleNews(start='24/01/2020', end='23/01/2021')
googlenews.search('Domestic violence')
result = googlenews.result()
df = pd.DataFrame(result)
print(df.head())
for i in range(2,20):
googlenews.getpage(i)
result = googlenews.result()
df = df.append(result)
df = pd.DataFrame(df)
Many thanks!
Solution 1:[1]
I found the answer. I wrote the dateformat wrong. It should have been 01/24/2020
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | semchena31 |