找回密码
 加入
搜索
查看: 4239|回复: 4

[网络通信] 查找网页内字符串,匹配后执行程序或快捷键

[复制链接]
发表于 2010-4-4 12:11:07 | 显示全部楼层 |阅读模式
http://blog.sina.com.cn/guodegang

要求很简单,当这个博客的访问量到某值(这个可以自定义,如果能做到匹配多处更好,我只需要一处)时自动截图保存在某处

PS:要自动后台执行

PS2:如果有类似的软件可以达到这目的,麻烦说一下名字即可
发表于 2010-4-4 12:20:18 | 显示全部楼层
发一段我写好的,给你参考
Func readcheck()
        $dxsz=IniReadSection("config.ini","对象设置")
        If not @error Then
        For $i = 1 To $dxsz[0][0]
                Sleep(2000)
                ;名称$dxsz[$i][0]
                ;网址$dxsz[$i][1])
        $checkresult = checktext($dxsz[$i][1],$dxsz[$i][0])
                If $checkresult = "1" Then
                        Sleep(1000)
                ElseIf $checkresult = "0" Then
                        Writelog("错误","检测 "&$dxsz[$i][1]&" 页面内容不包含"""&$dxsz[$i][0]&"""")
                        fix()
                Else
                        Writelog("错误 | "&$checkresult,"检测 "&$dxsz[$i][1]&" 页面内容是否包含"""&$dxsz[$i][0]&"""时发生了未知错误.")
                        fix()
                EndIf
        Next
Else
                Writelog("错误","无法读取检测对象,请检查配置文件.")
                sleep(1000)
        EndIf
       
EndFunc

Func checktext($url,$text)
        SplashTextOn("", "正在检查页面内容,请稍等", 220, 35, -1, -1, 33, "ARIAL", 9)
        Sleep(1000)
        FileDelete(@TempDir&"\CheckText.txt")
        InetGet($url,@TempDir&"\CheckText.txt",1,0)
     $htmlcontent = FileRead(@TempDir&"\CheckText.txt")
         $htmltitle = StringInStr ($htmlcontent, $text ,0,1)
         If $htmltitle ="0" Then ;失败
                 Return 0  
         Else
                 Return 1
         EndIf
EndFunc
发表于 2010-4-4 12:20:44 | 显示全部楼层
config.ini

[对象设置]
关键词=网址
 楼主| 发表于 2010-4-4 13:46:50 | 显示全部楼层
谢谢楼上...但是我是菜鸟,能不能指导一下?

1.这代码不需要修改关键字什么的吧?
2.config.ini里面怎么写? 最好有个例子
发表于 2010-4-14 22:08:17 | 显示全部楼层
我写了一个比较笨的方法,楼主可以尝试
#include <IE.au3> 

$URL = "http://blog.sina.com.cn/guodegang"
$oIE = _IECreate($URL)

Sleep(10000)

$content = _IEBodyReadText($oIE)

$index1 = StringInStr($content,"博客访问:")

$index2 = StringInStr($content,"关注人气")

$str = StringMid($content,$index1+5,$index2 - $index1 - 5)

$str = StringReplace($str,",","")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $str = ' & $str & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

$AcessNum = Number($str)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $AcessNum = ' & $AcessNum & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

If $AcessNum > 18000000 Then
        
        _ScreenCapture_Capture(@MyDocumentsDir & "\image.jpg")
        
        MsgBox(0,"SaveImage","图片保存在:" & @MyDocumentsDir & "\image.jpg");
        
EndIf

_IEAction($oIE,"quit")
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 06:06 , Processed in 0.085213 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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