This handles a lot of the repeating tags.
Code: Select all
#Persistent
xml := URL_ToVar("http://thale.accu-weather.com/widget/thale/weather-data.asp?location=37201")
while p := RegExMatch(xml, "Us)<day number=""(\d)"">(.+)</day>", m, p?p+1:1) { ;Search "<day number="x">...</day number="x">
RegExMatch(m2, "s)<daytime>.+</daytime>", d) ;<daytime>...</daytime>
day%m1%_daytime := d
RegExMatch(m2, "s)<nighttime>.+</nighttime>", n) ;<nighttime>...</nighttime>
day%m1%_nighttime := n
}
Loop, 5 {
i := A_Index, p :=0
while p := RegExMatch(day%i%_daytime, "Us)<([^/]+)>", m, p?p+1:1) ;<tags>
if RegExMatch(day%i%_daytime, "U)<.+>\K.+(?=</" m1 ">)", s, p) ;<tag>...</tag>
Day%i%_daytime_%m1% := s
p :=0
while p := RegExMatch(day%i%_nighttime, "Us)<([^/]+)>", m, p?p+1:1) ;<tags>
if RegExMatch(day%i%_nighttime, "U)<.+>\K.+(?=</" m1 ">)", s, p) ;<tag>...</tag>
Day%i%_nighttime_%m1% := s
}
ListVars
return
URL_ToVar(URL) {
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", URL)
WebRequest.Send()
return, WebRequest.ResponseText
}
Esc::
ExitApp
Edit: See these two links to learn more about how RegEx works:
RegExMatch and
RegEx Quick Reference. If you have any questions don't hesitate to ask.