tqt129 Posted August 16, 2006 Share Posted August 16, 2006 has anyone seen a script that check for all link on a website and report back which one is dead? possible? Link to comment Share on other sites More sharing options...
lod3n Posted August 16, 2006 Share Posted August 16, 2006 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] Link to comment Share on other sites More sharing options...
tqt129 Posted August 16, 2006 Author Share Posted August 16, 2006 (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 August 16, 2006 by tqt129 Link to comment Share on other sites More sharing options...
lod3n Posted August 16, 2006 Share Posted August 16, 2006 if $size <> 0 then filewriteline("log.txt","Good: "& $oLink.href) else filewriteline("log.txt","Bad: "& $oLink.href) endif [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
tqt129 Posted August 16, 2006 Author Share Posted August 16, 2006 if $size <> 0 thenfilewriteline("log.txt","Good: "& $oLink.href)elsefilewriteline("log.txt","Bad: "& $oLink.href)endifwow it is kinda slow..but hopefully it works =) Link to comment Share on other sites More sharing options...
lod3n Posted August 16, 2006 Share Posted August 16, 2006 (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 August 16, 2006 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
tqt129 Posted August 16, 2006 Author Share Posted August 16, 2006 (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 August 16, 2006 by tqt129 Link to comment Share on other sites More sharing options...
lod3n Posted August 16, 2006 Share Posted August 16, 2006 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] Link to comment Share on other sites More sharing options...
tqt129 Posted August 17, 2006 Author Share Posted August 17, 2006 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 =) Link to comment Share on other sites More sharing options...
lod3n Posted August 17, 2006 Share Posted August 17, 2006 Oh, I get it. if @ERROR <> 1 then filewriteline("log.txt","Good: "& $oLink.innerText & "[" & $oLink.href & "]") else filewriteline("log.txt","Bad: "& $oLink.innerText & "[" & $oLink.href & "]") endif [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
tqt129 Posted August 22, 2006 Author Share Posted August 22, 2006 Oh, I get it. if @ERROR <> 1 then filewriteline("log.txt","Good: "& $oLink.innerText & "[" & $oLink.href & "]") else filewriteline("log.txt","Bad: "& $oLink.innerText & "[" & $oLink.href & "]") endif ok 1 more requestion =). instead of $oIE = _IECreate ( "http://www.example.com/"). how about a popup prompt asking what URL i want to look at Link to comment Share on other sites More sharing options...
Zedna Posted August 22, 2006 Share Posted August 22, 2006 ok 1 more requestion =). instead of . how about a popup prompt asking what URL i want to look atLook in HelpFile for InputBox(). Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
tqt129 Posted August 22, 2006 Author Share Posted August 22, 2006 #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 Link to comment Share on other sites More sharing options...
lod3n Posted August 22, 2006 Share Posted August 22, 2006 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] Link to comment Share on other sites More sharing options...
tqt129 Posted August 23, 2006 Author Share Posted August 23, 2006 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 Link to comment Share on other sites More sharing options...
lod3n Posted August 23, 2006 Share Posted August 23, 2006 Ah. Well, if it's not responding, try killing AutoIt3.exe in TaskManager.Hey, I should mention, I found a cool 404 detection method posted by DaleHohm right here:http://www.autoitscript.com/forum/index.php?showtopic=22343You might be able to use this instead. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
tqt129 Posted August 24, 2006 Author Share Posted August 24, 2006 Ah. Well, if it's not responding, try killing AutoIt3.exe in TaskManager.Hey, I should mention, I found a cool 404 detection method posted by DaleHohm right here:http://www.autoitscript.com/forum/index.php?showtopic=22343You might be able to use this instead.its responding, here do this ...run the program..then hit hte cancel button...even though you hit cancel or click the X ...the script still process Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now