|
本帖最后由 link369 于 2010-8-9 22:42 编辑
$array = StringRegExp($HTMLContents, $kaishi&'[^\<]+'&$jieshu, 2, $nOffset)
这里标志位可以写为4为全局,但是这里改为4以后就没办法打开提取到的地址进行播放地址的提取。
我要实现的就是输入电影名称然后在优酷里面搜索的相关内容,然后全部把搜索出来的地址都列出来#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Include <GuiListBox.au3>
#Include <GuiImageList.au3>
$AForm1 = GUICreate("youku查找", 644, 432, 206, 119)
$Label1 = GUICtrlCreateLabel("电影名称:", 36, 30, 55, 17)
$Input1 = GUICtrlCreateInput("", 100, 25, 191, 21)
$Edit2 = GUICtrlCreateEdit("", 20, 60, 602, 360,$ES_AUTOVSCROLL)
GUICtrlSetColor(-1, 0x008000)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("开 始", 530, 10, 91, 41, 0)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
While 1
$nMsg1 = GUIGetMsg()
Select
Case $nMsg1 = $GUI_EVENT_CLOSE
ExitLoop
Case $nMsg1 = $Button2
$dy_name = GUICtrlRead($Input1)
if $dy_name = '' or $dy_name = '请输入电影名称' then
MsgBox (0,'提示:',"请先输入电影名称!!!")
else
GUICtrlSetData($Edit2, '')
caiji($dy_name)
EndIf
EndSelect
WEnd
func caiji($dy_name)
$nOffset = 1
$kaishi = '<li class="vTitle"><a href="' ;开始地址
$jieshu = '" charset="' ;结束地址
$url = '' ;分析到的连接
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET","http://www.soku.com/search_video/q_"&$dy_name)
$oHTTP.Send()
$HTMLContents = $oHTTP.Responsetext
if $HTMLContents <> "" then
$array = StringRegExp($HTMLContents, $kaishi&'[^\<]+'&$jieshu, 2, $nOffset)
If @error = 0 Then
$nOffset = @extended
EndIf
for $i = 0 to UBound($array) - 1
$url=$array[$i]
Next
$url=StringReplace($url,$kaishi,"")
$url=StringReplace($url,$jieshu,"")
if $url ="" then
GUICtrlSetData($Edit2, "电影名称错误或者目标站没有该电影!!!"&@CRLF, 1)
else
GUICtrlSetData($Edit2, "页面地址:"&$url&@CRLF, 1)
caiji_sj($url,$dy_name)
EndIf
Else
GUICtrlSetData($Edit2, "连接目标失败,请检查网络连接!!!"&@CRLF, 1)
EndIf
EndFunc
Func caiji_sj($url,$dy_name)
$nOffset = 1
$kaishi = ' <input type="text" id="link2" value="' ;开始地址
$jieshu = '" />' ;结束地址
$aa = '' ;分析到的连接
$ooHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$ooHTTP.Open("GET",$url)
$ooHTTP.Send()
$HTMLContents = $ooHTTP.Responsetext
if $HTMLContents <> "" then
$array = StringRegExp($HTMLContents, $kaishi&'[^\<]+'&$jieshu, 2, $nOffset)
If @error = 0 Then
$nOffset = @extended
EndIf
for $a = 0 to UBound($array) - 1
$aa=$array[$a]
Next
$aa=StringReplace($aa,$kaishi,"")
$aa=StringReplace($aa,$jieshu,"")
if $aa ="" then
GUICtrlSetData($Edit2, "没有找到!"&@CRLF, 1)
else
GUICtrlSetData($Edit2, "电影名称:"&$dy_name&" 播放地址:"&$aa&@CRLF, 1)
EndIf
Else
GUICtrlSetData($Edit2, "连接目标失败,请检查网络连接!!!"&@CRLF, 1)
EndIf
EndFunc
|
|