Page 1 of 1
Reading text from url [ SOLVED ]
Posted: 15 Aug 2012 22:00
by htb
I'm new to this forum so first I want to say Hi to every one

I want to ask one question. I found this code here
Code: Select all
@echo off
echo Set objHTTP = CreateObject("MSXML2.XMLHTTP")>>ip.vbs
echo Call objHTTP.Open("GET", "http://checkip.dyndns.org", False)>>ip.vbs
echo objHTTP.Send()>>ip.vbs
echo strHTML = objHTTP.ResponseText>>ip.vbs
echo wscript.echo strHTML>>ip.vbs
for /f "tokens=7 delims=:<" %%a in ('cscript /nologo "ip.vbs"') do set ip=%%a
echo %ip:~1%
pause
Is it posible to make it to read lets say from .txt
Example
http://mysite.com/text.txtI try but I cant make it. Can somebody help me.
Thanks
Re: Reading text from url
Posted: 15 Aug 2012 22:31
by foxidrive
What do you want to read from the website?
A third party tool called wget.exe will read web pages.
Re: Reading text from url
Posted: 15 Aug 2012 22:36
by htb
Yes, but after this code can display the info from the page ( you'r IP ) can it display some text from page?
Re: Reading text from url
Posted: 15 Aug 2012 22:45
by foxidrive
Here, try this. If you want something specific then describe what you want exactly.
Code: Select all
@echo off
echo Set objHTTP = CreateObject("MSXML2.XMLHTTP")>>ip.vbs
echo Call objHTTP.Open("GET", "http://www.dostips.com/forum/viewtopic.php?f=3&t=3656&view=unread#unread", False)>>ip.vbs
echo objHTTP.Send()>>ip.vbs
echo strHTML = objHTTP.ResponseText>>ip.vbs
echo wscript.echo strHTML>>ip.vbs
for /f "delims=" %%a in ('cscript /nologo "ip.vbs"') do echo %%a
del ip.vbs
pause
Re: Reading text from url
Posted: 15 Aug 2012 22:51
by htb
The first code I paste when you start it its shows you'r IP that takes it from
http://checkip.dyndns.org in the screen.
I'm looking for a way to display text from .txt or .html
Lets say I have
http://mysite.com/text.txt and in the .txt file I have " Hello "
When I start it in the place when now its displaying the IP I want to see " Hello "
Thanks
Re: Reading text from url
Posted: 15 Aug 2012 22:54
by foxidrive
Did you try the code above?
Re: Reading text from url
Posted: 15 Aug 2012 22:56
by htb
Oh yes, sorry very much. My fail
Can I use some how
I can find a way to make it. Thank you for you time

Re: Reading text from url
Posted: 15 Aug 2012 23:02
by htb
Sorry for the double post.
I found what I need

Code: Select all
@echo off
echo Set objHTTP = CreateObject("MSXML2.XMLHTTP")>>ip.vbs
echo Call objHTTP.Open("GET", "http://link.com/text.txt", False)>>ip.vbs
echo objHTTP.Send()>>ip.vbs
echo strHTML = objHTTP.ResponseText>>ip.vbs
echo wscript.echo strHTML>>ip.vbs
for /f "delims=" %%a in ('cscript /nologo "ip.vbs"') do set ip= %%a
echo %ip:~1%
echo %ip:~1%>>IP.txt
pause