My AHK toolset is still extremely limited, as you can probably tell.
I'm scraping a public website with no scraping restrictions. The working code is below.
1) I can use startVar to increment a counter here, I think because it never gets converted to a string during processing (not sure).
2) What I'd like to do (not only for this but for lots of other pages that use these ListView repeaters) is replace
"_2076ade26f0648268e57e8bd7e3c3bd1_ListView_ElementsRepeater_txt_1_" with a variable that will also get processed.
So far I've tried every escape sequence, double-quote and other trick I can think of, but the variable never gets processed.
Code: Select all
#SingleInstance, Force
pwb := WBGet()
URL = [URL omitted, but works fine]
pwb.Navigate(URL) ;Navigate to URL
while pwb.busy or pwb.ReadyState != 4 ;Wait for page to load
Sleep, 100
startVar := "0"
while startVar <=26 {
jName := pwb.document.GetElementByID("_2076ade26f0648268e57e8bd7e3c3bd1_ListView_ElementsRepeater_txt_1_"startVar).InnerText
jTCAA := pwb.document.GetElementbyID("_2076ade26f0648268e57e8bd7e3c3bd1_ListView_ElementsRepeater_txt_5_"startVar).InnerText
jPhone := pwb.document.GetElementbyID("_2076ade26f0648268e57e8bd7e3c3bd1_ListView_ElementsRepeater_txt_6_"startVar).InnerText
jInfo = %jName%|%jPhone%|%jTCAA% `r
FileAppend, %jInfo%, c:\test\judgescrape2.txt
startVar++
}
I've tried things like:
FF = `"_2076ade26f0648268e57e8bd7e3c3bd1_ListView_ElementsRepeater_txt_1_`"
FF := ""_2076ade26f0648268e57e8bd7e3c3bd1_ListView_ElementsRepeater_txt_1_""
FF = `_2076ade26f0648268e57e8bd7e3c3bd1_ListView_ElementsRepeater_txt_1_
The replacement would read something like "jName := pwb.document.GetElementByID(FFstartVar).InnerText". I hope I'm getting my concept across, although I'm afraid maybe not.
In the long run, I can keep on using the variables like they are, as they work fine, but I'd love to simplify them.
Regards,
W.