CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
About trapping HTTP 404 errors

 



daryl552007
Novice

Jul 13, 2009, 12:41 AM

Post #1 of 9 (929 views)
About trapping HTTP 404 errors Can't Post

HI guys,

I am working on a scraping script which would visit several pages. the problem is, there are some pages which dont exist and I get a 404 error. How do i trap this error and print a custom message on my terminal? like when the page is there i would print "page found" on my terminal, else "no page found".

Thanks in advance guys.


KevinR
Veteran


Jul 13, 2009, 10:10 AM

Post #2 of 9 (927 views)
Re: [daryl552007] About trapping HTTP 404 errors [In reply to] Can't Post

Look for the message "404 page not found" in the return request from the website and display your message accordingly.
-------------------------------------------------


daryl552007
Novice

Jul 13, 2009, 5:50 PM

Post #3 of 9 (924 views)
Re: [KevinR] About trapping HTTP 404 errors [In reply to] Can't Post

can you give me a chunk of code which I could use for this?I am really new to perl scraping and 404 error trapping is the roadblock i have right now.

Thanks


KevinR
Veteran


Jul 13, 2009, 6:32 PM

Post #4 of 9 (923 views)
Re: [daryl552007] About trapping HTTP 404 errors [In reply to] Can't Post

I would need to see your existing code to tell you how to do it within your current script. Otherwise all I can suggest is use a regexp:


Code
if ($return =~ /404 page not found/) { 
your error code here
}

-------------------------------------------------


daryl552007
Novice

Jul 13, 2009, 6:42 PM

Post #5 of 9 (922 views)
Re: [KevinR] About trapping HTTP 404 errors [In reply to] Can't Post

Imsorry but i think you misunderstood my question. What I meant was how do i get the value of the response variable? wherein I trace it for the not found string.

Thanks. Smile


KevinR
Veteran


Jul 14, 2009, 8:16 AM

Post #6 of 9 (919 views)
Re: [daryl552007] About trapping HTTP 404 errors [In reply to] Can't Post


In Reply To
Imsorry but i think you misunderstood my question. What I meant was how do i get the value of the response variable? wherein I trace it for the not found string.

Thanks. Smile


You said:


Quote
I am working on a scraping script which would visit several pages. the problem is, there are some pages which dont exist and I get a 404 error.


So where is the code you have written so far?
-------------------------------------------------


daryl552007
Novice

Jul 14, 2009, 8:29 AM

Post #7 of 9 (917 views)
Re: [KevinR] About trapping HTTP 404 errors [In reply to] Can't Post

I am already done with the scraping. Thanks anyway. You have been much help. I have another question though, How do i call a php program using perl and pass values to it?


KevinR
Veteran


Jul 14, 2009, 8:50 AM

Post #8 of 9 (916 views)
Re: [daryl552007] About trapping HTTP 404 errors [In reply to] Can't Post

I don't know
-------------------------------------------------


daryl552007
Novice

Jul 14, 2009, 9:17 AM

Post #9 of 9 (914 views)
Re: [KevinR] About trapping HTTP 404 errors [In reply to] Can't Post

Thanks anyway bro,

solved it already.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives