Jump to content

how to read file contents from google drive?


 Share

Recommended Posts

Hi friends,,
I'd like to get your help on how to read file contents on google drive which i have a shared file on there
I tried to do this 

#include <INet.au3>
Local Const $ini = _INetGetSource("https://docs.google.com/document/d/1JV1s3IueHLW6jMlCV_FSd0D8CBS-IpkS5b81VpZCmkk/edit?usp=sharing")

Local $url1 = IniRead($ini, 'Server', 'name', "")
MsgBox($MB_SYSTEMMODAL, "the Server name is", $url1)

Local $url2 = IniRead($ini, 'Username', 'name', "")
MsgBox($MB_SYSTEMMODAL, "the username is", $url2)

Local $url3 = IniRead($ini, 'Pass', 'name', "")
MsgBox($MB_SYSTEMMODAL, "the password is", $url3)

but unfortunately I got no results

Link to comment
Share on other sites

There is certainly a more clever way to do this ... :unsure:

#include <INet.au3>

$ini = @scriptdir & "\temp.ini"

$initxt = _INetGetSource("https://docs.google.com/document/d/1JV1s3IueHLW6jMlCV_FSd0D8CBS-IpkS5b81VpZCmkk/edit?usp=sharing")
$initxt = StringRegExpReplace($initxt, '(?s).*?og:description" content="([^"]+).*', "$1")
$initxt = StringReplace($initxt, '&#39;', "'")
$initxt = StringReplace($initxt, ' ', @crlf)
FileWrite($ini, $initxt)

Local $url1 = IniRead($ini, 'Server', 'name', "")
MsgBox($MB_SYSTEMMODAL, "the Server name is", $url1)

Local $url2 = IniRead($ini, 'Username', 'name', "")
MsgBox($MB_SYSTEMMODAL, "the username is", $url2)

Local $url3 = IniRead($ini, 'Pass', 'name', "")
MsgBox($MB_SYSTEMMODAL, "the password is", $url3)

 

Link to comment
Share on other sites

It's up to you. If you want to use the Ini* functions then you have to create somewhere a temp ini file (and delete it later) because these funcs need an existing file to be read
If you want no file, then as _INetGetSource returns the whole source code of the page as a string, you must use String* functions. In this case you might have the uploaded text as simple as possible, to make the script easier
Just an example below
 

#include <Array.au3>

; uploaded text as it could be returned by Inet + the 1st StringRegExpReplace from the previous script
$string = "Servername=mywebsite.com" & @crlf & "Username=sandanet" & @crlf & "Pass=123"
Msgbox(0,"", $string)

Msgbox(0,"Servername", StringRegExpReplace($string, '(?s).*Servername=(\S*).*', "$1") )
Msgbox(0,"Username", StringRegExpReplace($string, '(?s).*Username=(\S*).*', "$1") )
Msgbox(0,"Pass", StringRegExpReplace($string, '(?s).*Pass=(\S*).*', "$1") )

$res = StringRegExp($string, '=(\S*)', 3)
_ArrayDisplay($res)


 

Edited by mikell
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...