Jump to content

Recommended Posts

Posted

this is my code

why can' I get the http://blog.sina.com.tw/bwrbwrbqrthbby/article.php?pbgid=112619&entryid=668870 this page's html

It always read the http://blog.sina.com.tw/bwrbwrbqrthbby/ page's html

god please help me

 

#include <IE.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>

$oIE = _IECreate("http://blog.sina.com.tw/bwrbwrbqrthbby/")
_IELoadWait($oIE)

_IELinkGetCollection($oIE)
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
If $oLink.href = "http://blog.sina.com.tw/bwrbwrbqrthbby/article.php?pbgid=112619&entryid=668870" Then
_IEAction($oLink, "click")
_IELoadWait($oIE)
ExitLoop
EndIf
Next

Sleep(2000)

$sHTML = _IEDocReadHTML($oIE)

Posted

Hi @LeonLai, and welcome to the AutoIt forum :)

3 hours ago, LeonLai said:

It always read the http://blog.sina.com.tw/bwrbwrbqrthbby/ page's html

because of this:

3 hours ago, LeonLai said:

$oIE = _IECreate("http://blog.sina.com.tw/bwrbwrbqrthbby/")
$sHTML = _IEDocReadHTML($oIE)

You need to navigate to that link, and not just click it :)
Try this

If $oLink.href = "http://blog.sina.com.tw/bwrbwrbqrthbby/article.php?pbgid=112619&entryid=668870" Then
    _IENavigate($oIE, $oLink.href)
    ExitLoop
EndIf

$sHTML = _IEDocReadHTML($oIE)

and let us know ;)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted

If I change the code like this

#include <IE.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>

$oIE = _IECreate("http://blog.sina.com.tw/bwrbwrbqrthbby/")
_IELoadWait($oIE)

_IELinkGetCollection($oIE)
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
If $oLink.href = "http://blog.sina.com.tw/bwrbwrbqrthbby/article.php?pbgid=112619&entryid=668870" Then
_IEAction($oLink, "click")
_IELoadWait($oIE)
_IENavigate($oIE, $oLink)
ExitLoop
EndIf
Next

Sleep(2000)

$sHTML = _IEDocReadHTML($oIE)

 

and it just stop still can't read the html i need 

Posted (edited)

@LeonLai
Study this code:

#include <IE.au3>
#include <MsgBoxConstants.au3>

Global $oIE, _
       $oLinks, _
       $strLink = ""


Global $oIE = _IECreate("http://blog.sina.com.tw/bwrbwrbqrthbby/")
If @error Then
    ConsoleWrite("_IECreate() = Error: " & @error & @CRLF)
Else

    ConsoleWrite("START DEBUGGING:" & @CRLF & @CRLF)

    ConsoleWrite("_IECreate() = Ok" & @CRLF)
    Global $oLinks = _IELinkGetCollection($oIE)
    If @error Then
        ConsoleWrite("_IELinkGetCollection() = Error: " & @error & @CRLF)
    Else
        ConsoleWrite("_IELinkGetCollection() = Ok" & @CRLF)
        For $oLink In $oLinks
            If $oLink.href = "http://blog.sina.com.tw/bwrbwrbqrthbby/article.php?pbgid=112619&entryid=668870" Then
                ConsoleWrite("Link found! '" & $oLink.href & "'." & @CRLF)
                $strLink = $oLink.href

                ExitLoop
            EndIf
        Next

        ; Wait for the page to load => 10 seconds max
        _IELoadWaitTimeout(10000)

        _IENavigate($oIE, $strLink, 1)
        If @error = 6 Then ; $_IESTATUS_LoadWaitTimeout
            ConsoleWrite("_IENavigate() = Ok ( $_IESTATUS_LoadWaitTimeout )" & @CRLF)

            $sHTML = _IEDocReadHTML($oIE)
            If @error Then
                ConsoleWrite("_IEDocReadHTML() = Error: " & @error & @CRLF)
            Else
                ConsoleWrite("_IEDocReadHTML() = Ok" & @CRLF)
                ConsoleWrite("START HTML CODE: " & @CRLF & @CRLF & $sHTML & @CRLF & @CRLF & "END HTML CODE" & @CRLF)

                _IEQuit($oIE)
                If @error Then
                    ConsoleWrite("_IEQuit() = Error: " & @error & @CRLF)
                Else
                    ConsoleWrite("_IEQuit() = Ok" & @CRLF)
                EndIf
            EndIf
        ElseIf @error <> 6 Then
            ConsoleWrite("_IENavigate() = Error: " & @error & @CRLF)
        Else
            ConsoleWrite("?????" & @CRLF)
        EndIf
    EndIf

    ConsoleWrite(@CRLF & "END DEBUGGING" & @CRLF)

EndIf

 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted (edited)

@FrancescoDiMuro 

 

#include <IE.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>

$oIE = _IECreate("http://blog.sina.com.tw/bwrbwrbqrthbby/")
_IELoadWait($oIE)

_IELinkGetCollection($oIE)
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
If $oLink.href = "http://blog.sina.com.tw/bwrbwrbqrthbby/article.php?pbgid=112619&entryid=668870" Then
_IEAction($oLink, "click")
_IELoadWait($oIE)
ExitLoop
EndIf
Next

Sleep(2000)
$nIE = _IEAttach("新浪")
MsgBox($MB_SYSTEMMODAL, "The URL", _IEPropertyGet($nIE, "locationurl"))

_IEQuit($oIE)

Sleep(2000)

$sHTML = _IEDocReadHTML($oIE)

Edited by LeonLai
Posted
1 hour ago, LeonLai said:

_IEAction($oLink, "click")
_IELoadWait($oIE)

Are you still using this?
Did you read the example I posted?
I gave it to you for a purpose.
You don't have to click to the link as I've already told you, but you have to navigate to it.
Last message for me in this topic if you keep using this code.

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...