ich versuche folgenden Code zuverwenden:
Code: Alles auswählen
import urllib
from xml.dom import minidom
WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s'
WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0'
def weather_for_zip(zip_code):
url = WEATHER_URL % zip_code
dom = minidom.parse(urllib.urlopen(url))
forecasts = []
for node in dom.getElementsByTagNameNS(WEATHER_NS, 'forecast'):
forecasts.append({
'date': node.getAttribute('date'),
'low': node.getAttribute('low'),
'high': node.getAttribute('high'),
'condition': node.getAttribute('text')
})
ycondition = dom.getElementsByTagNameNS(WEATHER_NS, 'condition')[0]
return {
'current_condition': ycondition.getAttribute('text'),
'current_temp': ycondition.getAttribute('temp'),
'forecasts': forecasts,
'title': dom.getElementsByTagName('title')[0].firstChild.data
}
Unabhänig davon dass Yahoo diesen Url Dienst geändert hat kann ich diese Funktion nicht ausführen lassen.
Der Fehler lautet
Ich habe im Netz schon einige Foren durchsucht und wurde darauf aufmerksam, dass wohl mein PATH nicht richtig gesetzt wurde - deswegen habe ich folgendes gemachtTraceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "P:\*\TESTGEBIET\pprint.py", line 26, in <module>
weather_for_zip(21465)
File "P:\*\TESTGEBIET\pprint.py", line 9, in weather_for_zip
dom = minidom.parse(urllib.urlopen(url))
File "C:\Program Files\Python27\Lib\xml\dom\minidom.py", line 1919, in parse
from xml.dom import expatbuilder
File "C:\Program Files\Python27\Lib\xml\dom\expatbuilder.py", line 32, in <module>
from xml.parsers import expat
File "C:\Program Files\Python27\Lib\xml\parsers\expat.py", line 4, in <module>
from pyexpat import *
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.
Code: Alles auswählen
import sys
sys.path.append("C:/Program Files/Python27/Lib/xml/parsers/")
vielen Dank !