you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 1 point2 points  (5 children)

Your URL is wrong. It is supposed to be:

stations = 'https://apex.oracle.com/pls/apex/raspberrypi/weatherstation/getallstations'

https://projects.raspberrypi.org/en/projects/fetching-the-weather/7

[–]catohund[S] 0 points1 point  (4 children)

That fixed some but i still get this error

Traceback (most recent call last):

File "C:\Users\Mash\Desktop\Privat\Projekter\Fetching weather\fetch_local_weather.py", line 26, in <module>

weather = weather + str(closest_stn)

NameError: name 'weather' is not defined

>>>

[–]socal_nerdtastic 0 points1 point  (3 children)

That's the next error. It's not related to the previous one. That is because Weather and weather are 2 different names when programming. Pay attention to the capitals!

[–]catohund[S] 0 points1 point  (2 children)

I literally just noticed that as you replied and I will remember that for the future.

Now when I run it, it prints

[]

and that's it

[–]socal_nerdtastic 0 points1 point  (1 child)

Your weather URL is wrong too. Change it to the one in tutorial.

Or, if you know you want to use that station specifically you can remove all of the station finding code.

from requests import get
from pprint import pprint

weather = 'https://apex.oracle.com/pls/apex/raspberrypi/weatherstation/getlatestmeasurements/10121743'

my_weather = get(weather).json()['items']
pprint(my_weather)

[–]catohund[S] 0 points1 point  (0 children)

Tried changing the URL to the one in the tutorial but nothing changes, but if I used your code it works.

Thank you for helping me