Closed giovannifi closed 2 years ago
I think the problem is that FuelWatch changed the permissions for the RSS page http://fuelwatch.wa.gov.au/fuelwatch/fuelWatchRSS
I tried to run the following code:
import requests
url = 'http://fuelwatch.wa.gov.au/fuelwatch/fuelWatchRSS?'
response = requests.get(url)
print(response)
and I get "Response [403] - forbidden". This indicates that the server understand the request but it does not authorise it. This must be the reason why fuelwatcher is returning an empty variable.
Thanks for raising this issue.
I conducted some quick testing and am pretty confident that the Fuel Watcher server is just scanning for user agent strings and denying requests based on that.
To test this yourself try:
import requests
url = 'http://fuelwatch.wa.gov.au/fuelwatch/fuelWatchRSS?'
response = requests.get(url, headers={"User-Agent": "googlebot"}) # anything but the default python/requests
print(response)
I am working on a more persistent and reliable fix. In the short term please checkout the #35 pull request.
@giovannifi please try the latest version of fuelwatcher
.
You can ensure the most recent version is installed by pinning the package.
# requirements.txt
fuelwatcher==0.2.3
# or in a shell
pip install fuelwatcher==0.2.3
thanks. By mistake I run the command
pip install fuelwatcher --upgrade
and this installed the version 0.2.21. I tested it and it seems to work now.
Glad to hear its working. 👌
Every time I run the command:
api.query(day='yesterday', brand=20, product=1)
it returns an empty variable (None). I also tried the command reported on the PiPy webpage (https://pypi.org/project/fuelwatcher/):
api.query(product=2, region=25, day='yesterday')
and again I got an empty value (returns None)
is this the correct behaviour?
I suspect that the format of the FuelWatch XML RSS changed and therefore the api is not able to grab the info anymore.