找回密码
 加入
搜索
查看: 1747|回复: 12

HTML代码提取

  [复制链接]
发表于 2009-11-27 01:56:34 | 显示全部楼层 |阅读模式
本帖最后由 qq3911909 于 2009-11-27 06:16 编辑

不知道我这样写的代码是否有问题...还请大侠知道,,,刚学AUTOIT没几天...顺便能找个师傅最好,我只会问师傅一些关键的地方,不会一有问题就问的...我QQ3911909
#include <String.au3>
#include <IE.au3> 
#Include <GuiListView.au3>
_Main()
func _Main();分析网页获取连接,下载到TEMP文件夹
;For $urlx = 16379 to 16382 Step 1
Dim $s_Start = '<h2>'
$s_End = '下载页面'
$d_Start = "下载地址列表"
$d_End = " 第1部分(3GP格式)"
Dim $url="http://www.80s.cn/MovieDownloadsSubMod.aspx?formatid=2&movieid=16379"
InetGet($url,'temp\temp.txt',0,0)
;IniWrite ("D:\AU3\IE\url.ini", "电影", "网页代码", $HTMLContents )
$HTMLContents=FileRead('temp\temp.txt')
Local $dyname = _StringBetween($HTMLContents,$s_Start,$s_End)
Local $dyurl =  _StringBetween($HTMLContents, $d_Start, $d_End)
IniWrite ("D:\AU3\IE\temp\url.ini", "电影", "电影名", $dyname[0])
IniWrite ("D:\AU3\IE\temp\url.ini", "电影", "下载路径", $dyurl[0])
EndFunc
发表于 2009-11-27 02:11:15 | 显示全部楼层
标题好像有问题。小心哦!
 楼主| 发表于 2009-11-27 02:37:30 | 显示全部楼层
本帖最后由 qq3911909 于 2009-11-27 02:40 编辑
标题好像有问题。小心哦!
bing614 发表于 2009-11-27 02:11

知道了..谢谢提醒...不知道我上面的代码是否哪里有写错..或者缺什么吗?
发表于 2009-11-27 02:58:21 | 显示全部楼层
回复 3# qq3911909


    你自己测试没? 这样至少会有数组问题
 楼主| 发表于 2009-11-27 03:17:54 | 显示全部楼层
回复  qq3911909


    你自己测试没? 这样至少会有数组问题
afan 发表于 2009-11-27 02:58


自己测试很多回了...好像得到的都是0..
不知道问题出在哪里...
是不支持带换行符还是其他什么问题呢?/
版主不知道可以加我QQ,我好有些问题可以请教呢.

还有你说的数组问题...我不清楚什么东西...刚学AUTOIT.,,,很多东西都还不明白,,,
发表于 2009-11-27 03:19:53 | 显示全部楼层
$HTMLContents=FileRead('temp\temp.txt')
后面加一句
msgbox(0,0,$HTMLContents)
你就知道读取到的东西是什么了
发表于 2009-11-27 03:27:44 | 显示全部楼层
#include <String.au3>
Local $Url = "http://www.80s.cn/MovieDownloadsSubMod.aspx?formatid=2&movieid=16379"
Local $InetRead = InetRead($Url), $_Title, $_StrSplt, $i, $_temp, $_temp1, $_String
If $InetRead <> "" Then $InetRead = BinaryToString($InetRead, 4)
$_Title = _StringBetween($InetRead, "<h2>", "</h2>")
If IsArray($_Title) Then $_Title = StringReplace($_Title[0], "下载页面", "")
$_String &= $_Title & @CRLF
$_StrSplt = _StringBetween($InetRead, '<a href="#"', "</a>")
If IsArray($_StrSplt) Then
        For $i = 0 To UBound($_StrSplt) - 1
                $_temp = _StringBetween($_StrSplt[$i], "/>" & @CRLF, ")")
                If IsArray($_temp) Then $_temp = StringStripWS($_temp[0], 8) & ")"
                $_temp1 = _StringBetween($_StrSplt[$i], 'onclick="FlashgetDown(', ",'80410');return false;")
                If IsArray($_temp1) Then $_temp1 = $_temp1[0]
                $_String &= $_temp & " : " & $_temp1 & @CRLF
        Next
EndIf
FileWrite("test.txt", $_String)
MsgBox(0, "", $_String)
用正则也可以.
 楼主| 发表于 2009-11-27 03:37:30 | 显示全部楼层
$HTMLContents=FileRead('temp\temp.txt')
后面加一句
msgbox(0,0,$HTMLContents)
你就知道读取到的东西 ...
afan 发表于 2009-11-27 03:19

代码是读取了到了..
截取出了问题....
不能活着中间的代码...
发表于 2009-11-27 03:38:35 | 显示全部楼层
回复 8# qq3911909


    LS已经帮你搞定了~
 楼主| 发表于 2009-11-27 03:47:26 | 显示全部楼层
用正则也可以.
bing614 发表于 2009-11-27 03:27


谢谢,,,我在电脑运行报错....不知道怎么回事..
 楼主| 发表于 2009-11-27 03:48:47 | 显示全部楼层
刚刚测试了下...脚本没有问题..是我的笔记本安装的是Win7,刚刚在另外一个Windows2003系统上测试没有问题...
谢谢
发表于 2009-11-27 04:37:00 | 显示全部楼层
正则方式:
For $urlx = 16379 To 16382
        Local $Url = "http://www.80s.cn/MovieDownloadsSubMod.aspx?formatid=2&movieid=" & $urlx
        Local $InetRead = InetRead($Url), $HTMLContents, $sR, $sR2
        If $InetRead <> "" Then $HTMLContents = BinaryToString($InetRead, 4)
        $sR = StringRegExp($HTMLContents, '<h2>《.(.*).》下载页面', 3)
        If @error = 0 Then
                $sR = StringRegExpReplace($sR[0], "\[|\]", '"')
                $sR2 = StringRegExp($HTMLContents, '<a href.+onclick=.FlashgetDown..(.+).,.+return false;.\s+.+\s+([^<]+)</a>', 3)
                If @error = 0 Then
                        For $i = 0 To UBound($sR2) - 1 Step 2
                                IniWrite("url.ini", $sR, $sR2[$i + 1], $sR2[$i] & '/')
                        Next
                EndIf
        EndIf
Next
If MsgBox(64 + 4, 0, '已完成,是否打开ini查看?') = 6 Then ShellExecute("url.ini")
 楼主| 发表于 2009-11-27 06:16:28 | 显示全部楼层
谢谢楼上两位....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-16 09:18 , Processed in 0.082289 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表