sandanet Posted December 5, 2017 Share Posted December 5, 2017 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 More sharing options...
mikell Posted December 5, 2017 Share Posted December 5, 2017 There is certainly a more clever way to do this ... #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, ''', "'") $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) sandanet 1 Link to comment Share on other sites More sharing options...
sandanet Posted December 5, 2017 Author Share Posted December 5, 2017 (edited) Thank you Mr.mikell for your help, but is it possible to do it without write any file on the pc even without use delete file command? Edited December 6, 2017 by sandanet Link to comment Share on other sites More sharing options...
mikell Posted December 6, 2017 Share Posted December 6, 2017 (edited) 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 December 6, 2017 by mikell sandanet 1 Link to comment Share on other sites More sharing options...
sandanet Posted December 6, 2017 Author Share Posted December 6, 2017 (edited) ArrayDisplay function do the job but i think there should be a (for .. net) loop at the end in order to assign each number of row to a variable (&url1, &url2 and &url3) right ? Edited December 6, 2017 by sandanet Link to comment Share on other sites More sharing options...
mikell Posted December 6, 2017 Share Posted December 6, 2017 Right But please keep in mind that my example is nothing but an example, to show the concept. Depending on how the uploaded text is written/formatted, the way to extract the data (the regex pattern) may be slightly different Link to comment Share on other sites More sharing options...
sandanet Posted December 6, 2017 Author Share Posted December 6, 2017 yes you are right, the way of written data in a txt file need to have rewrite the regex pattern in a proper way.. i agree with you. But your example really was very useful for me thank you alot Link to comment Share on other sites More sharing options...
mikell Posted December 7, 2017 Share Posted December 7, 2017 You're welcome, glad I could help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now