找回密码
 加入
搜索
查看: 1320|回复: 2

[IE类操作] 读取网页中的文字(已解决)

[复制链接]
发表于 2020-7-19 14:54:59 | 显示全部楼层 |阅读模式
本帖最后由 xymc 于 2020-7-20 18:57 编辑

l

https://lol.qq.com/news/index.shtm
想读取公告列表里面的文字
直接读网页源码里面是没有公告内容的
有什么办法可以读取到公告列表里面的文字
已解决,谢谢A大afan提供的方案







发表于 2020-7-19 17:42:45 | 显示全部楼层


_IEBodyRead      html  你获取不到,那就 获取  Text 。只要是显示 出来的,都能获取
发表于 2020-7-19 17:37:55 | 显示全部楼层
A大剑指源头……………………

提供一种模拟移动鼠标到LI上面,激活后读源码:(这种网页直接_IELinkClickByText没效果???)
模拟移动有局限性,目前测试是可以读取到内容——————坐等更稳妥的解答————[password]
#include <Array.au3>
#include <IE.au3>
$oIE = _IEAttach("https://lol.qq.com/news/index.shtml", "url")
$hIe=_IEPropertyGet($oIE,"hwnd")
WinActivate($hIe)

Local $oLIs = _IETagNameGetCollection($oIE, "LI")
For $oLI In $oLIs
        If $oLI.innertext = '公告 ' Then
                $oIE.document.documentElement.scrollTop= 0 ;防止定位不准确,先滚动到top,模拟点击局限性…不能后台获取…故前面需要WinActivate
                
                ; 获取文本区域的坐标和尺寸
                Local $iScreenX = _IEPropertyGet($oLI, "screenx")
                Local $iScreenY = _IEPropertyGet($oLI, "screeny")
                Local $iWidth = _IEPropertyGet($oLI, "width")
                Local $iHeight = _IEPropertyGet($oLI, "height")

                ; 移动鼠标到区域中心停止移动
                Local $iMousespeed = 1
                MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed)
                ExitLoop
        EndIf
Next

$sSource = _IEDocReadHTML($oIE)
Local $aSRE = StringRegExp($sSource, "'newdList-inform\d+','(.*?)'\);", 3)
_ArrayDisplay($aSRE, 'Debug~~~')
[/password]
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-2 05:30 , Processed in 0.073835 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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