#include <Array.au3>
#include <INet.au3>
#include<Array.au3>
Local $passnum=0
$Ti=InputBox("起始货号", "请输入您希望查询的起始货号的网址最后面的数字例如id=1509,请输入1509", "", " M4")
Local $OutF="",$passnum=0
While $passnum<20
$s_URL = 'http://www.ysxyfs.com/goods.php?id='&$Ti
$sText = _INetGetSource($s_URL)
If Not StringRegExp($sText, 'Keywords.+content="[^"]+') Then
;~ Local $Array=StringRegExp($sText,"(?msi)(?>[\x{4e00}-\x{9fa5}]+:[^<&]+)|(颜色.*?)(大小.*?)(?:购买数量)",3)
Local $Array=StringRegExp($sText,"(?ms)(货号[^<]+).*?(库存[^<]+).*?(商品品牌[^<]+).+?(上架时间[^<]+).+(本店价:)<[^>]+>([^<]+).+?(颜色.*?)(大小.*?)购买数量",3)
Local $Output=""
For $i=0 To UBound($Array)-1
If StringRegExp($Array[$i],'[<>]') Then
$temp_Array=StringRegExp($Array[$i],'(?msi)\<label\h*for[^>]+\V\s+\<[^>]+\V\s+(.*?)\s+\<\/label\>',3)
Local $temp=""
For $k=0 To UBound($temp_Array)-1
$temp&=StringRegExpReplace($temp_Array[$k],'[\s]+'," ")&" "
Next
$Array[$i]=$temp
$Output&=$temp&" "
Else
$Output&=$Array[$i]
EndIf
$Output&="|"
Next
$OutF&=$Output&@CRLF
MsgBox(0,0,$OutF)
$Ti+=1
$passnum=0
Else
$passnum+=1
EndIf
WEnd
FileWrite(@DesktopDir&"\test.txt",$OutF)
MsgBox(4096, "已完成", "请查看桌面上查询结果.txt", 10)
|