read value from webpage and store it

Get help with using AutoHotkey and its commands and hotkeys
automatLife84
Posts: 23
Joined: 11 Jan 2019, 18:42

read value from webpage and store it

30 Apr 2019, 04:20

hi to all, i have a problem. I need to copy a number inside a web page
the web page is composed in this mode:


text ...................................

text ...................................

text ...................................

NUMBER:xxxxx

other text.....


i want store the number near the text NUMBER.. I think i have to copy with ctrl+a the entire webpage text and then filter text and copy the number..
Any suggest ?
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: read value from webpage and store it

30 Apr 2019, 21:51

You could use something like the following to retrieve the actual HTML code, so that you're not doing anything visible with the browser window and don't even need to have the browser window open:

Code: Select all

ComObjError(false)
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
( proxy && http.SetProxy(2, proxy) )
http.open( "GET", "http://www.gog.com", 1 )
http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
http.send("q=" . URIEncode(str))
http.WaitForResponse(-1)
MsgBox, % http.responsetext

URIEncode(str, encoding := "UTF-8")  {
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &var, encoding)

   While code := NumGet(Var, A_Index - 1, "UChar")  {
      bool := (code > 0x7F || code < 0x30 || code = 0x3D)
      UrlStr .= bool ? "%" . Format("{:02X}", code) : Chr(code)
   }
   Return UrlStr
}
I ripped that from the GoogleTranslate.ahk script.

Return to “Ask For Help”

Who is online

Users browsing this forum: andrey_jb15, chenzhipeng, DRocks, flyingDman, Getfree, Google [Bot], TAC109 and 113 guests