Author Topic: [Python] Check links  (Read 3572 times)

0 Members and 1 Guest are viewing this topic.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
[Python] Check links
« on: 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

Offline neusbeer

  • Knight
  • **
  • Posts: 223
  • Cookies: 11
  • Beer makes you stronger XD
    • View Profile
    • http://www.facebook.nl/hackneus
Re: [Python] Check links
« Reply #1 on: 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
?
--Neusbeer

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Python] Check links
« Reply #2 on: 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.

Offline NeX

  • Peasant
  • *
  • Posts: 74
  • Cookies: 5
    • View Profile
Re: [Python] Check links
« Reply #3 on: 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..

Offline neusbeer

  • Knight
  • **
  • Posts: 223
  • Cookies: 11
  • Beer makes you stronger XD
    • View Profile
    • http://www.facebook.nl/hackneus
Re: [Python] Check links
« Reply #4 on: January 20, 2012, 08:31:30 pm »
yes I know.. but that's a slow method.. (which I'm using now)..
--Neusbeer

Offline xzid

  • Knight
  • **
  • Posts: 329
  • Cookies: 41
    • View Profile
Re: [Python] Check links
« Reply #5 on: 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

Code: [Select]
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: [Select]
~/code/rb $ ./httpcheck < hosts.txt > good.txt
« Last Edit: January 20, 2012, 10:02:24 pm by xzid »

Offline neusbeer

  • Knight
  • **
  • Posts: 223
  • Cookies: 11
  • Beer makes you stronger XD
    • View Profile
    • http://www.facebook.nl/hackneus
Re: [Python] Check links
« Reply #6 on: January 22, 2012, 12:41:56 am »
Gonna test this one..
Ruby is rather new for me.  looks not to harshe.. thnxs
--Neusbeer

Offline xzid

  • Knight
  • **
  • Posts: 329
  • Cookies: 41
    • View Profile
Re: [Python] Check links
« Reply #7 on: 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.

Offline neusbeer

  • Knight
  • **
  • Posts: 223
  • Cookies: 11
  • Beer makes you stronger XD
    • View Profile
    • http://www.facebook.nl/hackneus
Re: [Python] Check links
« Reply #8 on: January 22, 2012, 12:24:25 pm »
looks alot like perl.. can be ancestors or such..

--Neusbeer

Offline Flikka

  • Banned leecher
  • Peasant
  • *
  • Posts: 56
  • Cookies: -65527
  • Life isn't fair. We all learn it the hard way.
    • View Profile
Re: [Python] Check links
« Reply #9 on: 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?
My name is:
01000110 01101100 01101001 01101011 01101011 01100001

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Python] Check links
« Reply #10 on: 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.
« Last Edit: January 24, 2012, 08:38:51 am by Kulverstukas »

Offline imation

  • Peasant
  • *
  • Posts: 141
  • Cookies: 2
    • View Profile
Re: [Python] Check links
« Reply #11 on: January 24, 2012, 09:43:17 am »
OH very nice, thak you. this will make life easier