lanfengc 发表于 2010-3-1 17:10:13

留言板留言读取[已解决]

本帖最后由 lanfengc 于 2010-4-9 16:08 编辑

#include <INet.au3>
$File=InetGet("http://58.ieeie.com/58/book.aspx?username=lanfenglovec",@TempDir&"\temp.htm",1,0)
$Code=FileRead(@TempDir&"\temp.htm" )
$Code=StringSplit($Code,"查看留言",1)
$Code=StringSplit($Code,"首页",1)
$Code=StringSplit($Code,"STYLE33",1)
MsgBox(0,"总留言条数为",$Code)

For $i=2 To $Code Step 1
        $Fir=StringSplit($Code[$i],'STYLE29"'&'>',1)
        $1=StringSplit($Fir,"</sp",1)
        $1=StringTrimLeft($1,5)
        $2=StringSplit($Fir,"</sp",1)
        $2=StringTrimLeft($2,5)
        MsgBox(0,$1,"留言内容:"&$2)
Next

afan 发表于 2010-3-1 17:52:44

InetGet("http://58.ieeie.com/58/book.aspx?username=lanfenglovec", @TempDir & "\temp.htm", 1, 0)
$Code = FileRead(@TempDir & "\temp.htm")
$ID = StringRegExp($Code, '网友留言:([^<]+)</', 3)
If @error Then Exit MsgBox(0, 0, '错误1')
$str = StringRegExp($Code, 'STYLE29\">\s+([^<]+)\r\n</span><', 3)
If @error Then Exit MsgBox(0, 0, '错误2')
Dim $out = ''
For $i = 0 To UBound($ID) - 1
        $out &= 'ID:' & @CRLF & $ID[$i] & @CRLF & '内容:' & @CRLF & $str[$i] & @CRLF & @CRLF
Next
MsgBox(0, '共 ' & UBound($ID) & ' 条留言', $out)

lanfengc 发表于 2010-3-5 21:14:13

回复 2# afan


    AFAN 正则厉害顶一个。
页: [1]
查看完整版本: 留言板留言读取[已解决]