通过POST如何登陆网易邮箱?
$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.如果登录成功后,如何显示登陆成功的网页.最后一句不成功. 在线等,求大神们赐教,感激... 本帖最后由 80ren 于 2012-4-24 08:58 编辑
回复 2# showshow
LZ 有兴趣 m: hi@junguoguo.com 回复 3# 80ren
懂的话,就帮忙讲解下哈 上面的问题都纠结了几天了,很想弄个明白.各位大大们,求解决 在线求解,各路高手,恳请帮忙解答下,感激 post的内容应该都是可以通过Httpwatch获取的,可以查看post的数据,那个http://mail.163.com 是请求的地址,应该post请求中是可以看到的 以前用php 试过 好像163 邮箱登陆要跳转好多次 要连续抓好几次才行 不是一次登陆就可以了。 试过用 IE.au3 的函数实现登录163免费邮, 但没实现写信发信等操作...因工作关系, 也没兴趣研究了...
但毕竟学过几天的网页操作, 所以知道, 像楼主这类的POST操作已经'过时'了...
现在的POST, 兴的是用 'WinHttp_GetRespond'.
论坛里已有不少相关帖子, 自己搜索一下吧. 记得给分
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
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
$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
EndIf
$objEmail=""
EndFunc ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
$oMyRet = $HexNumber
$oMyRet = StringStripWS($oMyError.description, 3)
ConsoleWrite("### COM Error !Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet & @LF)
SetError(1); something to check for when this function returns
Return
EndFunc ;==>MyErrFunc 这个东西用批处理来的容易些吧! 实用就好,不存在过时 'WinHttp_GetRespond' 学习,帮顶 最近也在研究这呢,学习下
页:
[1]