找回密码
 加入
搜索
查看: 11233|回复: 14

[IE类操作] 通过POST如何登陆网易邮箱?

 火.. [复制链接]
发表于 2012-2-7 09:50:12 | 显示全部楼层 |阅读模式
$xmlhttp=ObjCreate("Microsoft.XMLHTTP")
$poststr="savelogin=0&url2=http%3A%2F%2Fmail.163.com%2Ferrorpage%2Ferr_163.htm&username=abc123&password=123456789"
$xmlhttp.open("post","http://mail.163.com",false)
$xmlhttp.setRequestHeader("Cache-Control", "no-cache")
$xmlhttp.setRequestHeader("Connection", "Keep-Alive")
$xmlhttp.setRequestHeader("Accept-Language","zh-CN")
$xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$xmlhttp.setRequestHeader("Referer","http://mail.163.com/")
$xmlhttp.send($poststr)
ShellExecute("http://mail.163.com")
最近一直在学POST,可是总没头绪,坛里例子看了不少,可还是不能活用,大神们帮看下登陆网易邮箱的POST,试了不成功。
一直困扰我的有几个问题:
1.$xmlhttp.open("post","http://mail.163.com",false)这句中网址不知从什么地方获取,用Httpwatch在登陆成功的POST项不知道是哪个,是overview项的URL吗?
2.对于$xmlhttp.setRequestHeader()这几句,是从POST里的Header里吗,要全部写出来?
3.如果登录成功后,如何显示登陆成功的网页.最后一句不成功.
 楼主| 发表于 2012-2-7 12:06:20 | 显示全部楼层
在线等,求大神们赐教,感激...
发表于 2012-2-7 12:07:33 | 显示全部楼层
本帖最后由 80ren 于 2012-4-24 08:58 编辑

回复 2# showshow


    LZ 有兴趣 m: hi@junguoguo.com
 楼主| 发表于 2012-2-7 12:17:33 | 显示全部楼层
回复 3# 80ren

懂的话,就帮忙讲解下哈
 楼主| 发表于 2012-2-7 12:32:47 | 显示全部楼层
上面的问题都纠结了几天了,很想弄个明白.各位大大们,求解决
 楼主| 发表于 2012-2-7 13:46:59 | 显示全部楼层
在线求解,各路高手,恳请帮忙解答下,感激
发表于 2012-2-7 17:51:40 | 显示全部楼层
post的内容应该都是可以通过Httpwatch获取的,可以查看post的数据,那个http://mail.163.com 是请求的地址,应该post请求中是可以看到的
发表于 2012-2-8 01:46:13 | 显示全部楼层
以前用php 试过 好像163 邮箱登陆要跳转好多次 要连续抓好几次才行 不是一次登陆就可以了。
发表于 2012-2-8 02:29:59 | 显示全部楼层
试过用 IE.au3 的函数实现登录163免费邮, 但没实现写信发信等操作...因工作关系, 也没兴趣研究了...
但毕竟学过几天的网页操作, 所以知道, 像楼主这类的POST操作已经'过时'了...
现在的POST, 兴的是用 'WinHttp_GetRespond'.
论坛里已有不少相关帖子, 自己搜索一下吧.
发表于 2012-2-9 15:05:26 | 显示全部楼层
记得给分

By Jos@autoitscript
;
;##################################
; Include
;##################################
#Include<file.au3>
;##################################
; Variables
;##################################
$SmtpServer = "MailServer"              ; address for the smtp-server to use - REQUIRED
$FromName = "Name"                      ; name from who the email was sent
$FromAddress = "your@Email.Address.com" ; address from where the mail should come
$ToAddress = "your@Email.Address.com"   ; destination address of the email - REQUIRED
$Subject = "Userinfo"                   ; subject from the email - can be anything you want it to be
$Body = ""                              ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = ""                       ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
$CcAddress = "CCadress1@test.com"       ; address for cc - leave blank if not needed
$BccAddress = "BCCadress1@test.com"     ; address for bcc - leave blank if not needed
$Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
$Username = "******"                    ; username for the account used from where the mail gets sent - REQUIRED
$Password = "********"                  ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25                            ; port used for sending the mail
$ssl = 0                                ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465                          ; GMAIL port used for sending the mail
;~ $ssl=1                               ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Script
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf
;
; The UDF
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~          ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 then $IPPort = 25
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc
发表于 2012-2-9 18:30:06 | 显示全部楼层
这个东西用批处理来的容易些吧!
发表于 2012-2-10 16:14:38 | 显示全部楼层
实用就好,不存在过时
发表于 2012-2-19 14:29:42 | 显示全部楼层
'WinHttp_GetRespond'
发表于 2012-2-20 14:28:52 | 显示全部楼层
学习,帮顶
发表于 2012-2-28 09:40:14 | 显示全部楼层
最近也在研究这呢,学习下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 06:02 , Processed in 0.084209 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表