#include <WinHttp_GetRespond.au3>
$user = "user"
$pwd = "pwd"
$title = "标题"
$title = UrlEnc($title)
$content = "内容"
$content = UrlEnc($content)
;获取网页
$MyOpen=_WinHttpOpen()
$rContext=_WinHTTP_GetRespond($MyOpen,"https://www.xn--2lwy1a54b.tw:8443/cas-web/login?service=http%3A%2F%2Fwww.xn--2lwy1a54b.tw%3A8081%2Fc%2Fportal%2Flogin&",4 + 2 + 16,50000)
If @error Then
MsgBox(0,@error,"出错了")
Exit
EndIf
$lt = StringRegExp($rContext[0], 'name="lt" value="(.*)"', 3)
If Not IsArray($lt) Then
Exit
EndIf
;Post提交数据
$sPost = "username="&$user&"&passwordX="&$pwd&"&password="&$pwd&"<="&$lt[0]&"&_eventId=submit"
$rContext=_WinHTTP_GetRespond($MyOpen,"https://www.xn--2lwy1a54b.tw:8443/cas-web/login?service=http%3A%2F%2Fwww.xn--2lwy1a54b.tw%3A8081%2Fc%2Fportal%2Flogin&",1 + 4 + 2, 50000, $sPost, -1, "Content-Type: application/x-www-form-urlencoded")
If @error Then
MsgBox(0,@error,"出错了")
Exit
EndIf
;成功跳转
$location = StringRegExp($rContext[6], "Location: (.*)\n", 3)
If Not IsArray($location) Then
MsgBox(64, 0, "用户名或密码错误")
Exit
EndIf
$rContext=_WinHTTP_GetRespond($MyOpen, $location[0], 4 + 2 , 50000)
If @error Then
MsgBox(0,@error,"出错了")
Exit
EndIf
;~ FileWrite("成功后的网页.txt", $rContext[0])
;获取修改的时候需要的数据
$queeId = StringRegExp($rContext[0], '_DscMarquee_marqueeId=(.*)">', 3)
$userid = StringRegExp($rContext[0], '\?userid=(.*)&dateTime', 3)
$web = StringRegExp($rContext[0], 'href="(.*)" >新品公告', 3)
;获得成功后修改....还有日期那些我就不改了
$sPost = "_DscMarquee_marqueeId="&$queeId[0]&"&_DscMarquee_userId="&$userid[0]&"&_DscMarquee_cmd=update&_DscMarquee_redirect="&$web[0]&"&_DscMarquee_tabs1TabsScroll=&_DscMarquee_title="&$title&"&_DscMarquee_content="&$content&"&_DscMarquee_startDateYear=2011&_DscMarquee_startDateMonth=10&_DscMarquee_startDateDay=13&_DscMarquee_endDateYear=2011&_DscMarquee_endDateMonth=11&_DscMarquee_endDateDay=13"
$rContext=_WinHTTP_GetRespond($MyOpen,"http://www.xn--2lwy1a54b.tw:8081"&$web[0]&"?p_p_id=DscMarquee&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=view&_DscMarquee_struts_action=%2Fdsc%2Fdscmarquee%2Fedit_marquee",1 + 4 + 2, 50000, $sPost, -1, "Content-Type: application/x-www-form-urlencoded")
If @error Then
MsgBox(0,@error,"出错了")
Exit
EndIf
If StringInStr($rContext[0], "成功") Then
MsgBox(64, 0,"已经更改成功")
EndIf
FileWrite("5.txt", $rContext[0])
_WinHttpCloseHandle($MyOpen)
Func UrlEnc($Sz_url)
Local $str=StringTrimLeft(StringToBinary($Sz_url,4),2)
Local $ret
For $i=1 to StringLen($str) Step 2
$ret &='%' & StringMid($str,$i,2)
Next
Return $ret
EndFunc