Solved

Testing a URL

Posted on 1998-12-02
6
176 Views
Last Modified: 2010-03-04
I have a script in mind that will help me keep track of some of my links on my web page. I know how to do just about everything I am after. Only one problem. I need a little part of the script to test the URL I give it and tell me "GOOD" or "BAD".

For example, I could call a subroutine $good=&Test_URL("http:://www.test.com") and $good would contain 0 if the site responds with a 404 error, and 1 if anything else is returned.

Can you help with this subroutine please?
0
Comment
Question by:schworak
6 Comments
 
LVL 2

Expert Comment

by:irp
ID: 1206699
You could search for the word 404 in a response to a get from port 80 on the target server, however, this page contains a 404, in fact it contains two. How do you propose to distinguish these from real 404's (that's three now).
0
 
LVL 1

Expert Comment

by:adrianwatkins
ID: 1206700
if you were to create a routing I would you a telnet module as a starting point. Take the URL for example www.company.com/test.html split it into host and directory/file.

Now telnet host on port 80 and issue a get directory/file.

Now you will have to parse the response and decide what determines an error. However some 404 pages don't say much about them been a 404 on them - even though to be compliant the must.

Should take ~3/4 hours of playing look for telnet.pm to help with the socket stuff.


0
 
LVL 5

Expert Comment

by:b2pi
ID: 1206701
telnet??? Try perldoc lwpcook

use LWP::Simple;
$doc = get 'http://www.test.com";


will get you the source of what you're trying to find.  

use LWP::Simple;
($content_type, $document_length, $modified_time,  $expires, $server) = head("http://www.test.com");

will help you get around the 404 problem, too.

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 3

Author Comment

by:schworak
ID: 1206702
The telnet idea would work but is not reliable or predictable.

The LWP idea was the one I was looking for but couldn't find the docs on how to do it. Thanks.

The points will be awarded to b2pi if you just submit a message as an answer. Your answer is 100% what I am after. Thanks!
0
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1206703
telnet??? Try perldoc lwpcook

       use LWP::Simple;
       $doc = get 'http://www.test.com";


       will get you the source of what you're trying to find.  

       use LWP::Simple;
       ($content_type, $document_length, $modified_time,  $expires, $server) = head("http://www.test.com");

       will help you get around the 404 problem, too.






0
 
LVL 3

Author Comment

by:schworak
ID: 1206704
Thanks! The code works just great!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now