Need to use RegExMatch to get info. Please help.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
oldbrother
Posts: 275
Joined: 23 Oct 2013, 05:08

Need to use RegExMatch to get info. Please help.

12 May 2024, 17:06

I'm trying to get the information between "<table class="reportA">" and "<div class="foot"></div>" from website: https://q.stock.sohu.com/cn/002403/cwzb.shtml

But my code doesn't work. Help please!

Code: Select all

#Requires AutoHotkey v1

URL=https://q.stock.sohu.com/cn/002403/cwzb.shtml
info:=URLDownloadToVar(URL)

Needle = U)<table class="reportA">(.*)<div class="foot"></div>

RegExMatch(info,Needle,Data)

Info := Data1

msgbox % Info

Return

URLDownloadToVar(url,ByRef variable=""){
    hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
    hObject.Open("GET",url)
    hObject.Send()
    return variable:=hObject.ResponseText
}
User avatar
mikeyww
Posts: 27192
Joined: 09 Sep 2014, 18:38

Re: Need to use RegExMatch to get info. Please help.

12 May 2024, 17:14

Hello,

I am seeing 822 lines between those tags. What is the correct output that you seek?

"Doesn't work" indicates nothing in particular. What does your script do?

Code: Select all

#Requires AutoHotkey v1.1.33.11
url         := "https://q.stock.sohu.com/cn/002403/cwzb.shtml"
haystack    := URLDownloadToVar(url)
needleRegEx := "s)<table class=""reportA"">(.*?)<div class=""foot"">"
pos         := RegExMatch(haystack, needleRegEx, m)
MsgBox 64, Result, % m1
Return

URLDownloadToVar(url) {
 hObject := ComObjCreate("WinHttp.WinHttpRequest.5.1")
 hObject.Open("GET", url)
 hObject.Send()
 Return hObject.ResponseText
}
User avatar
oldbrother
Posts: 275
Joined: 23 Oct 2013, 05:08

Re: Need to use RegExMatch to get info. Please help.

12 May 2024, 17:29

Hi mikeyww, Thank you for your quick reply. Your code works! thank you so much! :thumbup: :thumbup: :thumbup:

Mine returns nothing.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: anidealworld, DevWithCoffee, Rohwedder and 65 guests