Pulling a Variable from HTML code

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jacksone
Posts: 3
Joined: 08 Feb 2023, 17:42

Pulling a Variable from HTML code

Post by jacksone » 08 Feb 2023, 17:49

Hi everyone! I'm relatively new to AHK but am somewhat familiar with the concept.

I'm looking for how do extract a variable from HTML data to define my own variable. I know where the variable is in the HTML code, just not how to extract it.

jacksone
Posts: 3
Joined: 08 Feb 2023, 17:42

Re: Pulling a Variable from HTML code

Post by jacksone » 08 Feb 2023, 18:14

To clarify further, I'm trying to pull a variable from whatever site I'm typing the hotkey in, not a static website.

gmoises
Posts: 74
Joined: 18 Nov 2017, 16:43

Re: Pulling a Variable from HTML code

Post by gmoises » 08 Feb 2023, 20:01

I guess the HTML code does not change much and you know the words before and after your variable data
This is a code I use a lot:
Sorry, the variable names are in Spanish

Code: Select all

Try
{
	; Get all the HTML in a variable
	Texto	:= GetHTTP(Página)

	; find the text
	Desde	:= "Version "
	Hasta	:= " Download size"
	Versión	:= RegExReplace(Texto, "s).+" . Desde . "(.+?)" . Hasta . ".+", "$1")
	Versión	:= ComponerVersion(Versión)
} Catch e
	Versión	:= "Timeout"

MsgBox % Versión 

jacksone
Posts: 3
Joined: 08 Feb 2023, 17:42

Re: Pulling a Variable from HTML code

Post by jacksone » 09 Feb 2023, 14:05

gmoises wrote:
08 Feb 2023, 20:01
I guess the HTML code does not change much and you know the words before and after your variable data
This is a code I use a lot:
Sorry, the variable names are in Spanish
Thanks for the code! Is there any chance you could quickly explain what each line is doing? Doesn't have to be super in-depth.

Post Reply

Return to “Ask for Help (v1)”