现在的位置: 首页 > 综合 > 正文

用AutoIT删除新浪微博关注博主-更稳定的方法

2012年10月21日 ⁄ 综合 ⁄ 共 1220字 ⁄ 字号 评论关闭

昨天发布的程序,到了另一个网络环境,竟然不工作。检查了发现,原因是新浪微博返回的HTML代码居然在不同的环境不一样。原因未知。但使用_IEAction函数失效。又花三小时用另一种方法,采用驱动鼠标的方法,应该是更加稳定的方法。代码如下:

#include <IE.au3>

$oIE = _IECreate("http://www.weibo.com/xxxxxx/follow?leftnav=1&wvr=4", 0, 1, 1,0)
WinSetState("[CLASS:IEFrame]","",@SW_MAXIMIZE)

Sleep(5000)

Local $oLinks = _IELinkGetCollection($oIE)
$sSearchString = "取消关注"
For $oLink in $oLinks
   Local $sLinkText = _IEPropertyGet($oLink, "innerText")
   If StringInStr($sLinkText, $sSearchString) Then
   Local $iScreenX = _IEPropertyGet($oLink, "screenx")
   Local $iScreenY = _IEPropertyGet($oLink, "screeny")
   Local $iWidth = _IEPropertyGet($oLink, "width")
   Local $iHeight = _IEPropertyGet($oLink, "height")
   MouseClick("left", $iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2)
  
   $oAllLinks = _IELinkGetCollection($oIE)
   $sConfirmString="确定"
   For $oConfirmButton in $oAllLinks
   Local $sConfirm = _IEPropertyGet($oConfirmButton, "innerText")
   If StringInStr($sConfirm, $sConfirmString) Then
   Local $iScreenX1 = _IEPropertyGet($oConfirmButton, "screenx")
   Local $iScreenY1 = _IEPropertyGet($oConfirmButton, "screeny")
   Local $iWidth1 = _IEPropertyGet($oConfirmButton, "width")
   Local $iHeight1 = _IEPropertyGet($oConfirmButton, "height")
   MouseClick("left", $iScreenX1 + $iWidth1 / 2, $iScreenY1 + $iHeight1 / 2)
   EndIf
   next
   EndIf
Next

 

抱歉!评论已关闭.