by effel » 24 Jul 2020, 09:46
ja es gibt zwei möglichkeiten die Datenbank anzusprechen. Ich nutze erstmal die andere bis ich die ganze Liste gefunden habe
Code: Select all
FileEncoding, UTF-8
existListe = Bahnhof_ID_Liste.txt
if not fileexist(existListe)
{
try
{
ToolTip Download DBase
UrlDownLoadToFile, https://ds100.frankfurtium.de/dumps/ds100.html, Bahnhof_ID_Liste.txt
ToolTip
}
catch e
{
ErrorMessage := "Ausnahme ausgelöst!`n`nWas: " e.what
. "`nDatei: " e.file
. "`nZeile: " e.line
. "`nNachricht: " e.message
. "`nZusatz: " e.extra
MsgBox,,ErrorMessage:, % ErrorMessage, 2
FileAppend, % ErrorMessage, ErrorMessage.txt
}
}
FileRead, bhid, Bahnhof_ID_Liste.txt
xfa=<tbody>
yfc=</tbody>
xIDb=
xIDb :=xStr(bhid,,xfa,xfc)
xIDb := StrReplace(xIDb, "</th>`n <td>", "</th><td>", 1)
BahnhofsArray := {} ; 'leeres' associative array
Loop, Parse, xIDb, `n, `r
{
{
IDa=<th id="
IDc=">
ID:=
ID:=xStr(A_LoopField,,IDa,IDc)
Citya=<th id="%ID%">%ID%</th><td>
Cityc=</td>
City:=
City:=xStr(A_LoopField,,Citya,Cityc)
if city<>
BahnhofsArray[City] := ID
}
}
;BahnhofsArray["Köln Hbf"] := "kk"
needle := "Köln Hbf"
MsgBox % BahnhofsArray[needle]
MsgBox % BahnhofsArray["Hamburg-Altona"]
MsgBox % BahnhofsArray["Osinowka Grenze RU"]
Code: Select all
xStr(ByRef H, C:=0, B:="", E:="",ByRef BO:=1, EO:="", BI:=1, EI:=1, BT:="", ET:="") {
Local L, LB, LE, P1, P2, Q, N:="", F:=0 ; xStr v0.97 by SKAN on D1AL/D343 @ tiny.cc/xstr
Return SubStr(H,!(ErrorLevel:=!((P1:=(L:=StrLen(H))?(LB:=StrLen(B))?(F:=InStr(H,B,C&1,BO,BI))?F+(BT=N?LB
:BT):0:(Q:=(BO=1&&BT>0?BT+1:BO>0?BO:L+BO))>1?Q:1:0)&&(P2:=P1?(LE:=StrLen(E))?(F:=InStr(H,E,C>>1,EO=N?(F
?F+LB:P1):EO,EI))?F+LE-(ET=N?LE:ET):0:EO=N?(ET>0?L-ET+1:L+1):P1+EO:0)>=P1))?P1:L+1,(BO:=Min(P2,L+1))-P1)
}
ja es gibt zwei möglichkeiten die Datenbank anzusprechen. Ich nutze erstmal die andere bis ich die ganze Liste gefunden habe
[code]FileEncoding, UTF-8
existListe = Bahnhof_ID_Liste.txt
if not fileexist(existListe)
{
try
{
ToolTip Download DBase
UrlDownLoadToFile, https://ds100.frankfurtium.de/dumps/ds100.html, Bahnhof_ID_Liste.txt
ToolTip
}
catch e
{
ErrorMessage := "Ausnahme ausgelöst!`n`nWas: " e.what
. "`nDatei: " e.file
. "`nZeile: " e.line
. "`nNachricht: " e.message
. "`nZusatz: " e.extra
MsgBox,,ErrorMessage:, % ErrorMessage, 2
FileAppend, % ErrorMessage, ErrorMessage.txt
}
}
FileRead, bhid, Bahnhof_ID_Liste.txt
xfa=<tbody>
yfc=</tbody>
xIDb=
xIDb :=xStr(bhid,,xfa,xfc)
xIDb := StrReplace(xIDb, "</th>`n <td>", "</th><td>", 1)
BahnhofsArray := {} ; 'leeres' associative array
Loop, Parse, xIDb, `n, `r
{
{
IDa=<th id="
IDc=">
ID:=
ID:=xStr(A_LoopField,,IDa,IDc)
Citya=<th id="%ID%">%ID%</th><td>
Cityc=</td>
City:=
City:=xStr(A_LoopField,,Citya,Cityc)
if city<>
BahnhofsArray[City] := ID
}
}
;BahnhofsArray["Köln Hbf"] := "kk"
needle := "Köln Hbf"
MsgBox % BahnhofsArray[needle]
MsgBox % BahnhofsArray["Hamburg-Altona"]
MsgBox % BahnhofsArray["Osinowka Grenze RU"][/code]
[code]xStr(ByRef H, C:=0, B:="", E:="",ByRef BO:=1, EO:="", BI:=1, EI:=1, BT:="", ET:="") {
Local L, LB, LE, P1, P2, Q, N:="", F:=0 ; xStr v0.97 by SKAN on D1AL/D343 @ tiny.cc/xstr
Return SubStr(H,!(ErrorLevel:=!((P1:=(L:=StrLen(H))?(LB:=StrLen(B))?(F:=InStr(H,B,C&1,BO,BI))?F+(BT=N?LB
:BT):0:(Q:=(BO=1&&BT>0?BT+1:BO>0?BO:L+BO))>1?Q:1:0)&&(P2:=P1?(LE:=StrLen(E))?(F:=InStr(H,E,C>>1,EO=N?(F
?F+LB:P1):EO,EI))?F+LE-(ET=N?LE:ET):0:EO=N?(ET>0?L-ET+1:L+1):P1+EO:0)>=P1))?P1:L+1,(BO:=Min(P2,L+1))-P1)
}[/code]