drislaam Posted January 25, 2009 Share Posted January 25, 2009 Hi, Actually I want to load a page from a forum but, The forum requires login first. I have tried to use InetGet("http://myuser:mypassword@www.somesite.com" , "test.html", 1) but nothing have been processed and the forum send to me the login page Any ideas on how to deal with cookies ..? Thanks, Link to comment Share on other sites More sharing options...
drislaam Posted January 26, 2009 Author Share Posted January 26, 2009 Waiting .... Link to comment Share on other sites More sharing options...
Authenticity Posted January 26, 2009 Share Posted January 26, 2009 InetGet won't help you in this case. Use _IECreate(), _IENavigate(), _IEFormGetObjByName(), _IEFormElementGetObjByName(), _IEFormElementSetValue(), _IEFormSubmit() --> all this can help you to achieve member log-on status and then use _IEDocReadHTML() or _IEBodyReadHTML() to get the entire or the body HTML. If the login process doesn't involve any Flash or Javascript techniques it will be a piece of cake, otherwise you'll need to play around to achieve the same like navigating to the javascript url that control submits etc.. Link to comment Share on other sites More sharing options...
AzKay Posted January 26, 2009 Share Posted January 26, 2009 (edited) http://www.autoitscript.com/forum/index.ph...my+http+wrapper$oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $sRet = _HTTPRequest($oHTTP, "POST", "http://site.com/login.php", "username=adasdasd&password=asdasdad") ConsoleWrite($sRet & @CRLF) Func _HTTPRequest($oHTTP, $oMethod, $oURL, $oData = "") $oHTTP.Open($oMethod, $oURL, False) If $oMethod = "POST" Then $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($oData) Return $oHTTP.ResponseText EndFunc Edited January 26, 2009 by AzKay # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
drislaam Posted January 26, 2009 Author Share Posted January 26, 2009 (edited) Thanks 'Authenticity' for your replying BUT could you please provide me with an example $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $sRet = _HTTPRequest($oHTTP, "POST", "http://www.autoitscript.com/forum/index.php?act=Login&CODE=00", "UserName=MYUSERNAME&PassWord=MYPASS") ConsoleWrite($sRet & @CRLF) Func _HTTPRequest($oHTTP, $oMethod, $oURL, $oData = "") $oHTTP.Open($oMethod, $oURL, False) If $oMethod = "POST" Then $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($oData) sleep(2000) Return $oHTTP.ResponseText EndFunc Thanks 'AzKay' for your replying I tried the previous code BUT It didn't work for me the server returns the login page :| Edited January 26, 2009 by drislaam Link to comment Share on other sites More sharing options...
AzKay Posted January 26, 2009 Share Posted January 26, 2009 You have to change the username=&password= POST data to whatever the servers login page uses. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
drislaam Posted January 26, 2009 Author Share Posted January 26, 2009 (edited) You have to change the username=&password= POST data to whatever the servers login page uses.Actually I did that for sureBUT I think the problem is with setting cookies I use it to fill simple form and it works greatlyBUT in case of login form in forums it return always login page.I appreciate indead your effort in helping me Edited January 26, 2009 by drislaam Link to comment Share on other sites More sharing options...
toxicvn Posted January 27, 2009 Share Posted January 27, 2009 $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $sRet = _HTTPRequest($oHTTP, "POST", "http://www.autoitscript.com/forum/index.php", "username=yourname&password=pass") ConsoleWrite($sRet & @CRLF) Func _HTTPRequest($oHTTP, $oMethod, $oURL, $oData = "") $oHTTP.Open($oMethod, $oURL, False) If $oMethod = "POST" Then $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($oData) Return $oHTTP.ResponseText EndFunc not working Link to comment Share on other sites More sharing options...
Authenticity Posted January 27, 2009 Share Posted January 27, 2009 (edited) expandcollapse popup#include <IE.au3> Opt('MustDeclareVars', 1) Yahoo_Login('Username@yahoo.com', 'Password##drowssaP', 'gwbush@ex-washington.us.org', 'Bye') Func Yahoo_Login($SFrom, $SPass, $sToMail = 'MyEmail@gmail.com', $sSubject = 'Hello') Local $oIE, $URL, $LoginForm, $user, $pass, $FormEle $URL = 'https://login.yahoo.com/config/mail?.intl=us' $oIE = _IECreate($URL, 0, 0) _IEPropertySet($oIE, 'silent', True) If _IEPropertyGet($oIE, "offline") Then _IEPropertySet($oIE, "offline", False) _IENavigate($oIE, $URL) EndIf $LoginForm = _IEFormGetObjByName($oIE, "login_form") $FormEle = _IEFormElementGetObjByName($LoginForm, "login") _IEFormElementSetValue($FormEle, $SFrom) $FormEle = _IEFormElementGetObjByName($LoginForm, "passwd") _IEFormElementSetValue($FormEle, $SPass) _IEFormSubmit($LoginForm, 0) _IELoadWait($oIE) _IENavigate($oIE, "http://us.mc1110.mail.yahoo.com/mc/welcome?action=&YY=ID&ymv=0&YY=ID&noFlush") $FormEle = _IEGetObjById($oIE, "global_compose_top") _IEAction($FormEle, "click") _IELoadWait($oIE) $LoginForm = _IEFormGetObjByName($oIE, "Compose") $FormEle = _IEFormElementGetObjByName($LoginForm, "to") _IEFormElementSetValue($FormEle, $sToMail) $FormEle = _IEFormElementGetObjByName($LoginForm, "Subj") _IEFormElementSetValue($FormEle, $sSubject) $FormEle = _IEFormElementGetObjByName($LoginForm, "send") _IEAction($FormEle, "click") _IELoadWait($oIE) _IEQuit($oIE) EndFunc It works but only if you got valid E-Mail and personalize the "http://us.mc1110.mail.yahoo.com/mc/welcome?action=&YY=ID&ymv=0&YY=ID&noFlush" - ID's with your user hash. Anyway, it's just examlpe =P Edited January 27, 2009 by Authenticity Link to comment Share on other sites More sharing options...
drislaam Posted January 27, 2009 Author Share Posted January 27, 2009 expandcollapse popup#include <IE.au3> Opt('MustDeclareVars', 1) Yahoo_Login('Username@yahoo.com', 'Password##drowssaP', 'gwbush@ex-washington.us.org', 'Bye') Func Yahoo_Login($SFrom, $SPass, $sToMail = 'MyEmail@gmail.com', $sSubject = 'Hello') Local $oIE, $URL, $LoginForm, $user, $pass, $FormEle $URL = 'https://login.yahoo.com/config/mail?.intl=us' $oIE = _IECreate($URL, 0, 0) _IEPropertySet($oIE, 'silent', True) If _IEPropertyGet($oIE, "offline") Then _IEPropertySet($oIE, "offline", False) _IENavigate($oIE, $URL) EndIf $LoginForm = _IEFormGetObjByName($oIE, "login_form") $FormEle = _IEFormElementGetObjByName($LoginForm, "login") _IEFormElementSetValue($FormEle, $SFrom) $FormEle = _IEFormElementGetObjByName($LoginForm, "passwd") _IEFormElementSetValue($FormEle, $SPass) _IEFormSubmit($LoginForm, 0) _IELoadWait($oIE) _IENavigate($oIE, "http://us.mc1110.mail.yahoo.com/mc/welcome?action=&YY=ID&ymv=0&YY=ID&noFlush") $FormEle = _IEGetObjById($oIE, "global_compose_top") _IEAction($FormEle, "click") _IELoadWait($oIE) $LoginForm = _IEFormGetObjByName($oIE, "Compose") $FormEle = _IEFormElementGetObjByName($LoginForm, "to") _IEFormElementSetValue($FormEle, $sToMail) $FormEle = _IEFormElementGetObjByName($LoginForm, "Subj") _IEFormElementSetValue($FormEle, $sSubject) $FormEle = _IEFormElementGetObjByName($LoginForm, "send") _IEAction($FormEle, "click") _IELoadWait($oIE) _IEQuit($oIE) EndFuncIt works but only if you got valid E-Mail and personalize the "http://us.mc1110.mail.yahoo.com/mc/welcome?action=&YY=ID&ymv=0&YY=ID&noFlush" - ID's with your user hash. Anyway, it's just examlpe =PThanks for example BUT the problem is it will be visible actions Link to comment Share on other sites More sharing options...
Authenticity Posted January 27, 2009 Share Posted January 27, 2009 So Change it in the line _IECreate($URL, 0, 0) to _IECreate($URL) or change later the property of the object , I.E, $oIE.Visible = True. 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