找回密码
 加入
搜索
查看: 12979|回复: 20

[IE类操作] [已解决]怎样用autoit采集网页上的数据到excel里面去?

 火... [复制链接]
发表于 2012-3-13 20:28:53 | 显示全部楼层 |阅读模式
本帖最后由 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                       

发表于 2012-3-13 21:03:52 | 显示全部楼层
你这个程序需要用到EXCEL文件的读写、网页文件的读取及网页内容的提取等知识呵。全部问人家,问题太大了啊。等于要人家给你写一个不太简短的完整的程序了。还是问题提得具体点比较好啊。
 楼主| 发表于 2012-3-13 21:15:43 | 显示全部楼层
完全不懂au,求高手写个,我好仔细学习,急需
发表于 2012-3-13 22:42:30 | 显示全部楼层
看看EXCEL方面的帮助文档!
 楼主| 发表于 2012-3-14 13:58:58 | 显示全部楼层
求高手狠狠写一个,就一个,谢谢啦
发表于 2012-3-15 17:31:03 | 显示全部楼层
自己动手..丰衣足食
发表于 2012-3-15 20:57:42 | 显示全部楼层

<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[4] Then ExitLoop
        Until $a[2]
        InetClose($hDownload)
        If Not $a[4] 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[1], $i, $j+2)
    Next

Next
MsgBox(0,"","3秒后自动关闭",3)
_ExcelBookClose($oExcel1, 1)
</au3>

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 2金钱 +20 贡献 +10 收起 理由
linjuming + 20 好厉害
zldfsz + 10 不错

查看全部评分

发表于 2012-3-15 21:19:25 | 显示全部楼层
回复 7# veket_linux


    非常好,另外高亮带码要将<au3>的尖括号<>改为中括号[]才行
 楼主| 发表于 2012-3-16 09:12:06 | 显示全部楼层
谢谢高手,真厉害啊
发表于 2012-3-16 10:33:27 | 显示全部楼层

#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[4] Then ExitLoop
        Until $a[2]
        InetClose($hDownload)
        If Not $a[4] 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[1], $i, $j+2)
    Next

Next
MsgBox(0,"","3秒后自动关闭",3)
_ExcelBookClose($oExcel1, 1)


看着方便点。

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2012-10-29 15:46:04 | 显示全部楼层
确实高手,谢谢共享
发表于 2012-12-5 22:49:12 | 显示全部楼层
的书法手动阀发大水的发的
发表于 2012-12-22 22:39:04 | 显示全部楼层
太强大了,学习拉
发表于 2012-12-22 22:39:11 | 显示全部楼层
太强大了,学习拉
发表于 2013-1-28 23:18:14 | 显示全部楼层
简单测试网址 都不可用了………………
想知道,"<(?i)li>(.*?)</(?i)li>" 中的  li 是什么…………
span倒是好理解…………
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-17 06:43 , Processed in 0.082810 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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