Chrome.ahk PageInst.Evaluate().value stuck

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Gh0sTG0
Posts: 55
Joined: 25 Jun 2018, 07:58

Chrome.ahk PageInst.Evaluate().value stuck

19 Nov 2018, 04:47

Hi everyone. I'm parsing some pages from chrome for links using chrome.ahk
It stuck on random place on page (it can be 1st page from script start. and it can be 5 or 10 page~) . And if I restart script on that page, it works correct.
What I have:

Code: Select all

PageInst := Chrome.GetPage(1)
While (flag = 1)
{
	numEl := PageInst.Evaluate("document.getElementsByClassName('class-name').length;").Value
	Loop %numEl%
	{
		lnk := "document.getElementsByClassName('class-name')[" . A_Index - 1 . "].href;"
		FileAppend, % "`n" . "1 " . numEl . " " . A_Index - 1 . " " . lnk, %LogFile%
		El := PageInst.Evaluate(lnk).Value
		FileAppend, % "`n" . "2 " . A_Index - 1 . " " . El, %LogFile%
		elL.Push(El)
	}
	[Some more code that works with links and then move to next page]
}
So, with that FileAppend's I find that it stuck on "El := PageInst.Evaluate(lnk).Value" in random place of the page.
If I double click on script in tray it is full of
245: Sleep,50 (0.05)
244: While,!this.responses[ID]
After that I'm checking my log and find that it's last string is
1 10 3 document.getElementsByClassName('class-name')[3].href;
Going to page->F12->insert document.getElementsByClassName('class-name')[3].href; in console->Enter.
And there's nothing interesting.
Link is standart for that site

Code: Select all

https://www.site.com/author/section/name-of-the-page-1234567890
Someone have any ideas about how to make it not stuck?
Based on LOG materials of 15+ stucks, so there's really nothing unifying in them.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: Chrome.ahk PageInst.Evaluate().value stuck

30 Nov 2018, 16:12

BTW you dont need the dot beetween the strings.
that was used in older scripts now deprecated.
Gh0sTG0
Posts: 55
Joined: 25 Jun 2018, 07:58

Re: Chrome.ahk PageInst.Evaluate().value stuck

30 Nov 2018, 16:27

SL5 wrote:
30 Nov 2018, 16:12
BTW you dont need the dot beetween the strings.
that was used in older scripts now deprecated.
There are alot of ways to merge strings in ahk, I like this one. Anyway, I think that problem is not in that string (or I'm not right?)
It tried Tooltip that string I have each time. It is not in string, because
1) it merge new string.
2) it tooltip it (I see that it is correct string, there's nothing that looks strange, no special symbols, unexpected dots, slashes, etc + I tried to output it to text file (to be sure), there's same result)
More, I add some tooltips into chrome.ahk (I write about that here)
Maybe this topic should be closed.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Lamron750 and 252 guests