Jump to content

Recommended Posts

Posted

Just combining some examples from the help file, here is a possible way of doing it. If $size is 0 then you could consider that the document is not there.

#include <IE.au3>
;$oIE = _IE_Example ("basic")
$oIE = _IECreate ( "http://www.example.com/")

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
    
    $size = InetGetSize ($oLink.href)
    MsgBox(0, "Link Info", $oLink.href & "Size: "& $size)
Next

You might run in to trouble with this being slow, or handling 404 redirects etc, but perhaps this will work for your needs?

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Posted (edited)

how do you output result to a text file instead of MSG pop up . kinda need to verify and parse the one with error

Edited by tqt129
Posted

if $size <> 0 then

filewriteline("log.txt","Good: "& $oLink.href)

else

filewriteline("log.txt","Bad: "& $oLink.href)

endif

wow it is kinda slow..but hopefully it works =)

Posted (edited)

You could maybe try INetGetSource instead:

#include <IE.au3>
#include <INet.au3>
;$oIE = _IE_Example ("basic")
$oIE = _IECreate ( "http://www.example.com/")

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks

    ;$size = InetGetSize ($oLink.href)
    _INetGetSource ( $oLink.href )

    ;if $size <> 0 then
    if @ERROR <> 1 then
        filewriteline("log.txt","Good: "& $oLink.href)
    else
        filewriteline("log.txt","Bad: "& $oLink.href)
    endif

Next
Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Posted (edited)

the second code you post seem to work. of course it return bad when the link require a password. Is there a way to display where the link is coming from? displaying whatever the text than the link its going to

Edited by tqt129
Posted

Well, if it requires a password, and you don't have it, it's bad anyway, right?

If you wanted to see where the link was being redirected to, you could do something like

;instaniate a new Internet Explorer object, and try and go to the page in question.
$oIE2 = _IECreate ($oLink.href)

;wait for it to load and trigger any redirects etc.
sleep(1000)

;wait for a potential redirect to finish redirecting
_IELoadWait ($oIE2)

$newurl = _IEPropertyGet ($oIE2, "locationurl")
if $newurl <> $oLink.href then filewriteline("log.txt","Bad: "& $oLink.href & @crlf & @tab & "Changed To:"&$newurl)

_IEQuit ($oIE2)

You get the idea

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Posted

Well, if it requires a password, and you don't have it, it's bad anyway, right?

If you wanted to see where the link was being redirected to, you could do something like

;instaniate a new Internet Explorer object, and try and go to the page in question.
$oIE2 = _IECreate ($oLink.href)

;wait for it to load and trigger any redirects etc.
sleep(1000)

;wait for a potential redirect to finish redirecting
_IELoadWait ($oIE2)

$newurl = _IEPropertyGet ($oIE2, "locationurl")
if $newurl <> $oLink.href then filewriteline("log.txt","Bad: "& $oLink.href & @crlf & @tab & "Changed To:"&$newurl)

_IEQuit ($oIE2)

You get the idea

actually i want to know where the link is coming from. say a link that say click "HERE" to go to this page. and if that link is bad, display both the word "HERE" and the URL(www.here.com)

thanks alot for helping me on this by the way...good help and learning experience =)

Posted

#include <IE.au3>
#include <INet.au3>
;$oIE = _IE_Example ("basic")
$oIE = _IECreate ( InputBox("Question", "Enter URL (www.yahoo.com, netzero.net)", "", "",))

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks

   ;$size = InetGetSize ($oLink.href)
    _INetGetSource ( $oLink.href )

   ;if $size <> 0 then
    if @ERROR <> 1 then
        filewriteline("good.txt","Good: "& $oLink.innerText & "[" & $oLink.href & "]")
    else
        filewriteline("bad.txt","Bad: "& $oLink.innerText & "[" & $oLink.href & "]")
    endif

Next

this is what i have so far, but when the prompt comes up and if i try to close it out..it still run the scripts and load a blank page with HTTP// url

Posted

Your code works perfectly for me, albeit slowly.

Are you putting in the whole url? Meaning "http://www.google.com" not "www.google.com"? Try putting in a tooltip status monitor, like so:

#include <IE.au3>
#include <INet.au3>
;$oIE = _IE_Example ("basic")
$oIE = _IECreate ( InputBox("Question", "Enter URL (www.yahoo.com, netzero.net)", "", "",))

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found",1)
For $oLink In $oLinks

   ;$size = InetGetSize ($oLink.href)
   tooltip("Checking: "& $oLink.innerText & "[" & $oLink.href & "]",0,0)
    _INetGetSource ( $oLink.href )

   ;if $size <> 0 then
    if @ERROR <> 1 then
        filewriteline("good.txt","Good: "& $oLink.innerText & "[" & $oLink.href & "]")
    else
        filewriteline("bad.txt","Bad: "& $oLink.innerText & "[" & $oLink.href & "]")
    endif

Next

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Posted

The code works, sorry for the bad english. What im saying is that i cant cancel the program by hitting cancel or clicking on the X. it still run

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...