[已解决]怎样用autoit采集网页上的数据到excel里面去?
本帖最后由 linjuming 于 2012-3-19 11:23 编辑几个简单测试网址:
网址 名称 材质 颜色
http://www.my-demo.info/au/a.html
http://www.my-demo.info/au/b.html
http://www.my-demo.info/au/c.html
http://i532.photobucket.com/albums/ee323/linjuming/questions/autoit_.png 你这个程序需要用到EXCEL文件的读写、网页文件的读取及网页内容的提取等知识呵。全部问人家,问题太大了啊。等于要人家给你写一个不太简短的完整的程序了。还是问题提得具体点比较好啊。 完全不懂au,求高手写个,我好仔细学习,急需 看看EXCEL方面的帮助文档! 求高手狠狠写一个,就一个,谢谢啦 自己动手..丰衣足食
<au3>
#include <array.au3>
#include <Excel.au3>
$xlsfile = @ScriptDir & "\abc.xls"
$oExcel1 = _ExcelBookOpen($xlsfile, 1)
For $i = 2 To 4
$read_link = _ExcelReadCell($oExcel1, $i, 1)
$bool = False
Do
If FileExists(@TempDir & "\tmp.html") Then FileDelete(@TempDir & "\tmp.html")
$hDownload = InetGet($read_link, @TempDir & "\tmp.html", 1, 1)
Do
Sleep(1000)
$a = InetGetInfo($hDownload, -1)
If $a Then ExitLoop
Until $a
InetClose($hDownload)
If Not $a Then $bool = True
Until $bool
$fp = FileOpen( @TempDir & "\tmp.html")
$read_buf = FileRead($fp)
FileClose($fp)
$array_1 = StringRegExp($read_buf, "<(?i)li>(.*?)</(?i)li>", 3)
For $j = 0 To UBound($array_1)-1
$array_2 = StringRegExp($array_1[$j], "<(?i)span>(.*?)</(?i)span>", 3)
_ExcelWriteCell($oExcel1, $array_2, $i, $j+2)
Next
Next
MsgBox(0,"","3秒后自动关闭",3)
_ExcelBookClose($oExcel1, 1)
</au3> 回复 7# veket_linux
非常好,另外高亮带码要将<au3>的尖括号<>改为中括号[]才行 谢谢高手,真厉害啊
#include <array.au3>
#include <Excel.au3>
$xlsfile = @ScriptDir & "\abc.xls"
$oExcel1 = _ExcelBookOpen($xlsfile, 1)
For $i = 2 To 4
$read_link = _ExcelReadCell($oExcel1, $i, 1)
$bool = False
Do
If FileExists(@TempDir & "\tmp.html") Then FileDelete(@TempDir & "\tmp.html")
$hDownload = InetGet($read_link, @TempDir & "\tmp.html", 1, 1)
Do
Sleep(1000)
$a = InetGetInfo($hDownload, -1)
If $a Then ExitLoop
Until $a
InetClose($hDownload)
If Not $a Then $bool = True
Until $bool
$fp = FileOpen( @TempDir & "\tmp.html")
$read_buf = FileRead($fp)
FileClose($fp)
$array_1 = StringRegExp($read_buf, "<(?i)li>(.*?)</(?i)li>", 3)
For $j = 0 To UBound($array_1)-1
$array_2 = StringRegExp($array_1[$j], "<(?i)span>(.*?)</(?i)span>", 3)
_ExcelWriteCell($oExcel1, $array_2, $i, $j+2)
Next
Next
MsgBox(0,"","3秒后自动关闭",3)
_ExcelBookClose($oExcel1, 1)
看着方便点。 确实高手,谢谢共享 的书法手动阀发大水的发的 太强大了,学习拉 太强大了,学习拉 简单测试网址 都不可用了………………
想知道,"<(?i)li>(.*?)</(?i)li>" 中的li 是什么…………
span倒是好理解…………
页:
[1]
2