找回密码
 加入
搜索
楼主: xiaozui

[IE类操作] 关于获取网页源码不完全的问题

 火... [复制链接]
发表于 2011-5-17 12:04:01 | 显示全部楼层
可以读取html源码之后,去获取标签中的值,不太会正则,用正则应该会简单些
 楼主| 发表于 2011-5-17 15:45:04 | 显示全部楼层
可以读取html源码之后,去获取标签中的值,不太会正则,用正则应该会简单些
kinghu318 发表于 2011-5-17 12:04


哥们,就是读取到的HTML源码中没有要要找的内容(这些内容用浏览器可以看见的,但用AU3获取的却没有)。
发表于 2011-5-17 16:21:37 | 显示全部楼层
回复 18# xiaozui

我看了下51的,他使用的框架,那里面显示的在线信息是显示在http://my.51.com/index.php这个页面的,你可以登录进去了之后看html源码<iframe id="oMain" name="oMain" width="100%" height="1024px" src="http://my.51.com/index.php" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowtransparency="true"></iframe>

</div>就是这段,是那个框架
 楼主| 发表于 2011-5-17 16:31:26 | 显示全部楼层
回复  xiaozui

我看了下51的,他使用的框架,那里面显示的在线信息是显示在这个页面的,你可以登录进去 ...
kinghu318 发表于 2011-5-17 16:21



  谢谢哥们,可是该怎么获取呢,我试好久都没能解决,劳烦兄弟再烦心下...
发表于 2011-5-17 17:12:25 | 显示全部楼层
回复 20# xiaozui

七楼的代码应该是可以的,你需要进行一个登录,然后才能获取吧
 楼主| 发表于 2011-5-18 14:17:30 | 显示全部楼层
回复  xiaozui

七楼的代码应该是可以的,你需要进行一个登录,然后才能获取吧
kinghu318 发表于 2011-5-17 17:12



    我已经登录了再获取的,不行
发表于 2011-5-19 09:47:35 | 显示全部楼层
回复 22# xiaozui


    我也试了下,不知道怎么去获取iframe里面的东西,登录进去获得的只是整个页面的源码,框架中的获取不到。。
发表于 2011-5-19 14:57:52 | 显示全部楼层
iframe里的东西同步获取需要cookie的
发表于 2011-5-22 08:33:57 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
Global $OEvent = ObjEvent("AutoIt.Error", "MyErrFunc")
Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
Global $YHM,$mm
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 203, 203, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Input1 = GUICtrlCreateInput("", 72, 24, 129, 21)
$Label1 = GUICtrlCreateLabel("用户名:", 24, 24, 43, 17)
$Label2 = GUICtrlCreateLabel("密  码:", 24, 51, 43, 17)
$Input2 = GUICtrlCreateInput("", 72, 48, 129, 21)
$Button1 = GUICtrlCreateButton("Button1", 32, 104, 161, 33)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        Sleep(100)
WEnd
Func _getString($sting,$bz)
        $prcs=StringSplit($sting,$bz,1)
        $prc=StringSplit($prcs[2],";")
        Return $prc[1]
EndFunc

Func Button1Click()
        $YHM=GUICtrlRead($Input1)
        $mm=GUICtrlRead($Input2)
        $oHTTP.SetTimeouts(15000, 15000, 15000, 15000) ;设置超时

        $oHTTP.Option(4) = 13056
        $oHTTP.Option(6) = True   ;为True时,当请求的页面中有跳转时,抓取跳转页面信息.False相反不抓取
        $oHTTP.open("POST","http://passport.51.com/login.5p",True)
        $oHTTP.setRequestHeader("Accept","application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*")
        $oHTTP.setRequestHeader("Accept-Encoding","gzip, deflate")
        $oHTTP.setRequestHeader("Accept-Language","zh-cn")
        $oHTTP.setRequestHeader("Cache-Control","no-cache")
        ;$oHTTP.setRequestHeader("Cookie", "string")    ;先设置一个cookie,防止出错,见官方文档
        ;$oHTTP.setRequestHeader("Cookie","passport_login_errorcode=; "& $PCCOOKIE)
        $oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
        $oHTTP.setRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
        $oHTTP.send("gourl=http://my.51.com&passport_51_password=" & $mm & "&passport_51_user=" & $YHM & "&passport_cookie_login=0")
        $oHTTP.WaitForResponse
        ;$ResponseText = BinaryToString ( $oHTTP.responseBody,4 )
        ;FileWriteLine(@ScriptDir&"\data.HTML",$ResponseText)
        Sleep(100)

        $oHTTP.open("GET","http://my.51.com/new.index.php",True)
        $oHTTP.setRequestHeader("Accept","application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*")
        $oHTTP.setRequestHeader("Accept-Encoding","gzip, deflate")
        $oHTTP.setRequestHeader("Accept-Language","zh-cn")
        $oHTTP.setRequestHeader("Cache-Control","no-cache")
        $oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
        $oHTTP.setRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
        $oHTTP.send("")
        $oHTTP.WaitForResponse
        ;$ResponseText = BinaryToString ( $oHTTP.responseBody,4 )
        $ResponseText = $oHTTP.ResponseText
        FileWriteLine(@ScriptDir&"\data.txt",$ResponseText)


EndFunc
Func Form1Close()
        Exit
EndFunc

Func MyErrFunc()
       
EndFunc

评分

参与人数 1金钱 +20 贡献 +1 收起 理由
xiaozui + 20 + 1 谢谢,哥们你真牛X

查看全部评分

发表于 2011-5-22 09:38:03 | 显示全部楼层
hehe
 楼主| 发表于 2011-5-23 21:06:43 | 显示全部楼层
#include
#include
#include
#include
#include
#include
Global $OEvent = ObjEvent("AutoIt. ...
zysanjing1 发表于 2011-5-22 08:33


谢谢哥们,终于成功了
发表于 2011-5-23 21:16:28 | 显示全部楼层
这个网站的COOKIE怎么这么麻烦,要想更详细操作请求高手分析网站代码
发表于 2011-6-9 00:43:01 | 显示全部楼层
情况比较严重,。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-16 21:45 , Processed in 0.071500 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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