kinghu318 发表于 2011-5-17 12:04:01

可以读取html源码之后,去获取标签中的值,不太会正则,用正则应该会简单些

xiaozui 发表于 2011-5-17 15:45:04

可以读取html源码之后,去获取标签中的值,不太会正则,用正则应该会简单些
kinghu318 发表于 2011-5-17 12:04 http://www.autoitx.com/images/common/back.gif

哥们,就是读取到的HTML源码中没有要要找的内容(这些内容用浏览器可以看见的,但用AU3获取的却没有)。

kinghu318 发表于 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>就是这段,是那个框架

xiaozui 发表于 2011-5-17 16:31:26

回复xiaozui

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


谢谢哥们,可是该怎么获取呢,我试好久都没能解决,劳烦兄弟再烦心下...

kinghu318 发表于 2011-5-17 17:12:25

回复 20# xiaozui

七楼的代码应该是可以的,你需要进行一个登录,然后才能获取吧

xiaozui 发表于 2011-5-18 14:17:30

回复xiaozui

七楼的代码应该是可以的,你需要进行一个登录,然后才能获取吧
kinghu318 发表于 2011-5-17 17:12 http://www.autoitx.com/images/common/back.gif


    我已经登录了再获取的,不行

kinghu318 发表于 2011-5-19 09:47:35

回复 22# xiaozui


    我也试了下,不知道怎么去获取iframe里面的东西,登录进去获得的只是整个页面的源码,框架中的获取不到。。

zysanjing1 发表于 2011-5-19 14:57:52

iframe里的东西同步获取需要cookie的

zysanjing1 发表于 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,";")
        Return $prc
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

qq82015930 发表于 2011-5-22 09:38:03

{:face (114):}hehe

xiaozui 发表于 2011-5-23 21:06:43

#include
#include
#include
#include
#include
#include
Global $OEvent = ObjEvent("AutoIt. ...
zysanjing1 发表于 2011-5-22 08:33 http://www.autoitx.com/images/common/back.gif

谢谢哥们,终于成功了

zysanjing1 发表于 2011-5-23 21:16:28

这个网站的COOKIE怎么这么麻烦,要想更详细操作请求高手分析网站代码

Netfox 发表于 2011-6-9 00:43:01

情况比较严重,。
页: 1 [2]
查看完整版本: 关于获取网页源码不完全的问题