There seems to be an issue with the office firewall in accessing GoogleNews api. Initially, the code below gave empty results. I am able to run the below code after I added proxy the environment variable in my user account
http_proxy http://abcd.mno.com:10023
https_proxy https://abcd.mno.com:10023
I was able to run it successfully both at command prompt as well as on Spyder. My current laptop is connected to work network thru vpn.
Now I wish to set up in another laptop. I hit the same issue. I have set the environment variable in my user account as above. The.condarc file also shows the above proxy_servers. But I am getting empty results. This laptop is in my office, connected to work network thru LAN
What can I do to ensure the proxy setting is properly configured?
The simplified code that I am using to test that the api is working is as below:
import pandas as pd
import os
import time
from GoogleNews import GoogleNews
from datetime import timedelta, date
googlenews = GoogleNews()
googlenews.search('Corona')
results = googlenews.result()
print(results)
So, if you have your own HTTP/HTTPS proxy(s) that you want to use to make requests to Google, that's how you do it:
gn = GoogleNews()
gn.top_news(proxies = {'https':'34.91.135.38:80'})
For more info please refer https://pypi.org/project/pygooglenews/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.