Jump to content

Forum login and cookies workout :(


 Share

Recommended Posts

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

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

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 by AzKay
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

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 by drislaam
Link to comment
Share on other sites

You have to change the username=&password= POST data to whatever the servers login page uses.

Actually I did that for sure

BUT I think the problem is with setting cookies

I use it to fill simple form and it works greatly

BUT in case of login form in forums it return always login page.

I appreciate indead your effort in helping me :)

Edited by drislaam
Link to comment
Share on other sites

$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

#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 by Authenticity
Link to comment
Share on other sites

#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

Thanks for example

BUT the problem is it will be visible actions :)

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...