此段代码是反复post得到最终的url跳转地址,可是为什么$a[4]=-1出错了呢?
#include "WinHttp_GetRespond.au3"
#include <Array.au3>
$PMID = "23313498"
Local $html = BinaryToString(InetRead("http://www.ncbi.nlm.nih.gov/pubmed/" & $PMID, 1), 1)
Local $icon = StringRegExp($html, '<a href="([^"]+).+?Icon for', 3)
If Not @error Then
MsgBox(0, 0, "iconurl " & $icon[0])
Local $a[8]
$a[4] = $icon[0]
;$a[4] = "http://linkinghub.elsevier.com/retrieve/pii/S0022-3913(14)00034-1";出错????????????
Do
$returnHead = $a[4]
_ArrayDisplay($a)
$a = _get($a[4])
Until $a[4] = -1 ;此处出错,为什么?
$afinal = $returnHead
MsgBox(48, "Final", $afinal)
EndIf
Func _get($sdurl, $sdcookie = "", $sdmoreheader = "");cookie 下载代码
Local $sdOpen, $sdContext
$sdOpen = _WinHttpOpen()
$sdmoreheader = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0"
$sdContext = _WinHTTP_GetRespond($sdOpen, $sdurl, 0 + 2 + 4 + 8, "", "", $sdcookie, $sdmoreheader)
;~ _ArrayDisplay($rContext)
If IsArray($sdContext) Then
Return $sdContext
Else
Return ""
EndIf
;_WinHttpCloseHandle($sdOpen)
EndFunc ;==>_get
|