EvilZone

Programming and Scripting => Scripting Languages => : Kulverstukas January 19, 2012, 03:44:04 PM

: [Python] Check links
: Kulverstukas January 19, 2012, 03:44:04 PM
Uhm this is a simple script I made to check a list of links for dead ones and pick out the good ones.
List is a text file with links. Usage is also simple: checkLinks.py filename
Good links will be output to a file named good_filename.

Script: checkLinks.py (http://newage.ql.lt/projects/python/checkLinks.py)
: Re: [Python] Check links
: neusbeer January 19, 2012, 04:22:35 PM
this one can be handy .. thnxs
does this also check file existence on sites?
if I have for example a large list with
http://<link>/pvt/serice.pwd
?
: Re: [Python] Check links
: Kulverstukas January 19, 2012, 05:50:30 PM
Sorry, no. It will only check if the link (or IP) is online and responsive. It does not check for file existence on remote hosts.
: Re: [Python] Check links
: NeX January 20, 2012, 05:25:31 PM
this one can be handy .. thnxs
does this also check file existence on sites?
if I have for example a large list with
http://<link>/pvt/serice.pwd
?

wget --spider does the job :D
You can then combine it with -i for input file, i.e. bookmars file, or whatever, and -o for output..
: Re: [Python] Check links
: neusbeer January 20, 2012, 08:31:30 PM
yes I know.. but that's a slow method.. (which I'm using now)..
: Re: [Python] Check links
: xzid January 20, 2012, 09:40:54 PM
this one can be handy .. thnxs
does this also check file existence on sites?
if I have for example a large list with
http://<link>/pvt/serice.pwd
?

in ruby

:
require 'net/http'
while x = gets
begin
    puts x if Net::HTTP.get_response(x.chomp, '/pvt/serice.pwd').is_a? Net::HTTPSuccess
rescue
end; end

run it:

:
~/code/rb $ ./httpcheck < hosts.txt > good.txt
: Re: [Python] Check links
: neusbeer January 22, 2012, 12:41:56 AM
Gonna test this one..
Ruby is rather new for me.  looks not to harshe.. thnxs
: Re: [Python] Check links
: xzid January 22, 2012, 02:32:12 AM
ruby is the lang I'm currently learning[~week], I already prefer it to python/perl. Seems you can hack stuff together very quickly which is exactly what I like(C is a different thing altogether)

... although in some ways it's unlike anything else I code, so I find it interesting.
: Re: [Python] Check links
: neusbeer January 22, 2012, 12:24:25 PM
looks alot like perl.. can be ancestors or such..

: Re: [Python] Check links
: Flikka January 24, 2012, 06:52:05 AM
could you help me with this?


I'm not a python-er-person,
so, how would i run this?
: Re: [Python] Check links
: Kulverstukas January 24, 2012, 08:38:20 AM
save it on a computer. If windows save where you installed Python. Open up the CMD (Terminal for linux/mac). Navigate to where you saved the script, write:
python checkLinks.py

Follow instruction from there.
: Re: [Python] Check links
: imation January 24, 2012, 09:43:17 AM
OH very nice, thak you. this will make life easier