Why getprint failed

W

Wuming Gong

Dear list,

I want to wrap this page
(http://www.dharmacon.com/sidesign/default.aspx?source=0) by perl
script, using LWP::UserAgent. However, the LWP cannot get the correct
content of this page :

$ perl -MLWP::Simple -e
'getprint("http://www.dharmacon.com/sidesign/default.aspx?source=0")'
500 Internal Server Error
<URL:http://www.dharmacon.com/sidesign/default.aspx?source=0>

But when I open this URL in firefox, the page can display well. Could
you please what is the problem and how deal with such page?

Thanks,

Wuming
 
P

Paul Lalli

Wuming said:
Dear list,

This is not a list. It is a Usenet Newsgroup. The difference is
significant.
I want to wrap this page
(http://www.dharmacon.com/sidesign/default.aspx?source=0) by perl
script, using LWP::UserAgent.

1) I don't know what "wrap" is supposed to mean in this context

2) Your code below does not use LWP::UserAgent (at least, not
explicitly)
However, the LWP cannot get the correct content of this page :

$ perl -MLWP::Simple -e
'getprint("http://www.dharmacon.com/sidesign/default.aspx?source=0")'
500 Internal Server Error
<URL:http://www.dharmacon.com/sidesign/default.aspx?source=0>

But when I open this URL in firefox, the page can display well.

Not for me, it doesn't. I get back an HTTP 500 error, albeit with a
significant amount of debugging information

If you want to get at the content of this HTTP 500 page, you cannot use
LWP::Simple (it's called "Simple" for a reason). Use the full fledged
LWP::UserAgent to examine the LWP::Response content attribute.

Paul Lalli
 
P

Paul Lalli

Paul said:
If you want to get at the content of this HTTP 500 page, you cannot use
LWP::Simple (it's called "Simple" for a reason). Use the full fledged
LWP::UserAgent to examine the LWP::Response content attribute.

Well, that's not strictly true. LWP::Simple can, in fact, export the
UserAgent it uses, so you could do this all without explicitly using
LWP::UserAgent or HTTP::Response:

perl -MLWP::Simple='$ua' -le'
$r=$ua->get("http://www.dharmacon.com/sidesign/default.aspx?source=0");

print $r->content
'

Paul Lalli
 
W

Wuming Gong

Thanks, Paul. But current problem is the link can be opened well under
firefox, while yield error message by LWP. Why such difference?

Wuming
 
P

Paul Lalli

Wuming said:
Thanks, Paul. But current problem is the link can be opened well under
firefox, while yield error message by LWP. Why such difference?

Please quote context when posting a reply. See that text above this
sentence? Where I quoted what you just wrote? That's context.
Compose any followups to this message in the same manner.

You are not understanding. Firefox is not opening the link
successfully. What is happening is that the CGI script that is
executing on the site is generating an error. The site's web server is
then returning a status 500, because there was an error. Firefox
retrieves that status code and displays the page that comes along with
it. A "normal", successful result is HTTP 200. This is the only
"success" code possible, and the only one LWP::Simple is built to
return. LWP::Simple will simply error out any other status code
returned. That's why it's "Simple". If you want something more
complex - like seeing an accompanying error document for a non-success
- you need to do something more complicated than Simple.

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,440
Latest member
YoungBorel

Latest Threads

Top