Jump to content
Israelks

Read text file from web

Recommended Posts

Israelks

Hi, I'm trying to read informations from a .txt stored file (i'm using drive to store the file, but i accept suggestions), I dont wanna use _IE because it is VERY slow for me, i've tried using InetRead and WinHTTP without success, here is my attempts: 

 

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "https://drive.google.com/open?id=1Cmk5-Mr10CwDcie37sb4AmhHj6D8S9C5", False)

$oHTTP.Send()
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
ConsoleWrite($oReceived)
ConsoleWrite(BinaryToString(InetRead("https://drive.google.com/open?id=1Cmk5-Mr10CwDcie37sb4AmhHj6D8S9C5",1)))
$oIE = _IECreate("https://drive.google.com/open?id=1Cmk5-Mr10CwDcie37sb4AmhHj6D8S9C5")
ConsoleWrite(_IEDocReadHTML($oIE)) <<<<< WORKING, BUT VERY SLOW

 Thanks!

Share this post


Link to post
Share on other sites
xCROv

Try _INetGetSource(). You will need to parse the info on your own though. If you're just looking to host a txt file then you can probably find a better way to do it that isn't google docs and will require less parsing.

#include <Inet.au3>

ConsoleWrite(_INetGetSource('https://drive.google.com/open?id=1Cmk5-Mr10CwDcie37sb4AmhHj6D8S9C5'))

https://www.autoitscript.com/autoit3/docs/libfunctions/_INetGetSource.htm

Edited by xCROv

Share this post


Link to post
Share on other sites
Israelks

Hi, thank you for your answer, 

Using INetGetSource i could not get the information stored (TEST123456), the results are the same as using InetRead and WinHTTP

Share this post


Link to post
Share on other sites
xCROv

It's because it's being hosted on Google Docs. Like I was saying, you will prob need to find a new method of storing the text online if you're wanting to do this without having to spend a lot more effort on parsing and getting the data.

#include <Inet.au3>

ConsoleWrite(_INetGetSource('http://xcrov.com/autoit/test.txt'))

 

Share this post


Link to post
Share on other sites
Israelks

i've searched an alternative for drive but i could not find, can you suggest me a place to host a text file? (where i can edit the text and still with the same link) 

Thanks!

Share this post


Link to post
Share on other sites
xCROv

There is a UDF around here for google drive. I'm not sure if it still works because the last time I used it was like 5 years ago but you could try that. If you're not wanting to purchase a domain and hosting service then you could look at hosting a apache server on your computer or something. I'm sure there are free hosting sites somewhere. 

Share this post


Link to post
Share on other sites
Danyfirex

Hello. this should work.

 

Local $sText=BinaryToString(InetRead("https://drive.google.com/uc?id=1Cmk5-Mr10CwDcie37sb4AmhHj6D8S9C5&export=download"))
ConsoleWrite($sText & @CRLF)

Saludos

  • Like 1

Share this post


Link to post
Share on other sites
Israelks

Thanks alot! it worked!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×