Hello.
I need to read (and search for a string) a web page's source. Any help appreciated.
The search part i think i can handle, but haven't been able to find anything to get the web page source to a string/array/anything that i can manipulate.
I'd prefer a solution WITHOUT any external programs if possible.
How to read web page source?
Moderator: DosItHelp
Re: How to read web page source?
IMHO with pure batch this isn't possible, but you could use vbscript/jscript.
And use this from a batch file.
You could even embedd the vbs into your batch file if necessary.
jeb
And use this from a batch file.
Code: Select all
for /F "usebackq tokens=1-3 delims=," %%a in (`cscript /nologo GetHtml.vbs http://google.com/`) DO (
echo(%%a
)
Code: Select all
'GetHTML.vbs
URL = WScript.Arguments.Item(0)
Set WshShell = WScript.CreateObject("WScript.Shell")
Set http = CreateObject("Microsoft.XmlHttp")
http.open "GET", URL, FALSE
http.send ""
WScript.echo http.responseText
You could even embedd the vbs into your batch file if necessary.
jeb
Re: How to read web page source?
There are third party tools like Wget or cURL. By default you can't do that via batch.
Otherwise you could use VBScript or JScript (as jeb has been shown) if you need to get the source text without external tools.
Regards
aGerman
Otherwise you could use VBScript or JScript (as jeb has been shown) if you need to get the source text without external tools.
Regards
aGerman
Re: How to read web page source?
Thank you both for your quick replies!
I'll get back to you if I run into more trouble
I'll get back to you if I run into more trouble

Re: How to read web page source?
OK aGerman thank you, but can I parse my saved html file previously saved?