RE: LWP Help
From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of steve silvers Sent: 17 June 2009 17:27 To: perl-win32-users@listserv.activestate.com Subject: LWP Help I have my below snippet that when I run it from my website, it returns the query to Yahoo, but all the links are screwed up? That's a bit vague. What do you mean by screwed up? How do I fix this? Also how can I add multiple searches to this for one call. Thanks in advance. #!/usr/bin/perl use strict; use warnings; missing. Please include them. use LWP::UserAgent; print Content-type: text/html\n\n; my $ua = new LWP::UserAgent; my $url = http://search.yahoo.com/search?p=trucksfr=yfp-t-501toggle=1cop=msse i=UTF-8; my $response = $ua-get($url); if($response-content_type ne text/html){ die(Recieved content-type .$response-content_type., was looking for text/html.) } my $content = $response-content; # $content now holds the html page from google. print $content; Just a guess, but are the links in the returned document relative? If so, hava a look at the example code in the doco for HTML::LinkExtor. HTH -- Brian Raven This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: LWP Help please
From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of steve silvers Sent: 17 May 2009 21:10 To: perl-win32-users@listserv.activestate.com Subject: LWP Help please I have looked over the LWP documentation but still have trouble putting the pieces together. Can someone give me a snippet that shows me how to query google for something, and display the results. The examples only show how to match on something and just print that out. How do I display the results, or format the results? Retrieving the results of a google query can be very easy using LWP::Simple, as you can no doubt see from the documentation. In order to give a sensible answer to your question How do I display the results, or format the results? we will need to know what you mean by that, at least something less vague. As LWP is mainly concerned with retrieving data, it is unlikely to be involved, as your question seems to be more related to doing something with the data after retrieving it. HTH -- Brian Raven This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: LWP Help please
use LWP::UserAgent; my $ua = new LWP::UserAgent; my $url = http://www.google.ca/search?q=perl+lwp+tutorial;; my $response = $ua-get($url); if($response-content_type ne text/html){ die(Recieved content-type .$response-content_type., was looking for text/html.) } my $content = $response-content; # $content now holds the html page from google. print $content; OR: use LWP::Simple; my $url = http://www.google.ca/search?q=perl+lwp+tutorial;; my $content = get($url); die Couldn't get $url. unless defined $content; # $content now contains the html page from google. print $content; On Sun, May 17, 2009 at 2:10 PM, steve silvers stevesilv...@hotmail.com wrote: I have looked over the LWP documentation but still have trouble putting the pieces together. Can someone give me a snippet that shows me how to query google for something, and display the results. The examples only show how to match on something and just print that out. How do I display the results, or format the results? Thanks in advance. HotmailĀ® goes with you. Get it on your BlackBerry or iPhone. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: LWP help
Title: Message Lwp_example.pl is script. STATFILE is output. I changed the proxy server info to protect TI proprietary data, and changed the site that is being accessed (although result is the same). Brian Lasher Catalog DSP Product Engineering Best Practices and Yield Enhancement Team [EMAIL PROTECTED] 281-274-2913(W) 281-684-4699(C) 713-664-6240(H) 281-274-2279(F) -Original Message- From: Gardner, Sam [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 26, 2004 1:07 PM To: Lasher, Brian; Perl-Win32-Users Subject: RE: LWP help Kind of hard to tell, w/o seeing the script or knowing what page it is. . . Sam Gardner GTO Application Development Keefe, Bruyette Woods, Inc. 212-887-6753 -Original Message- From: Lasher, Brian [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 26, 2004 1:29 PM To: Perl-Win32-Users Subject: LWP help I wrote a script using the LWP module. At first I got error 500 (something about server does not exist). Realized by reading the docs that I had to define my proxy server. Not getting that error now, so I assume that fix worked. Now I'm getting error 404 (doc not found) for a site that I know is correct. Script replies the following: CODE: 404 STATUS: 404 Not Found CONTENT: !DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN htmlhead title404 Not Found/title /headbody h1Not Found/h1 pThe requested URL /04-05RD.txt was not found on this server./p hr / /body/html Anyone seen this? Is there something people can do to prevent LWP from pulling data from their server? Is there something I'm missing? -brian Brian Lasher Catalog DSP Product Engineering Best Practices and Yield Enhancement Team [EMAIL PROTECTED] 281-274-2913(W) 281-684-4699(C) 713-664-6240(H) 281-274-2279(F) lwp_example.pl Description: lwp_example.pl 20041028 This is libwww-perl-5.79 BASE: http://www.yahoo.com/ IS SUCCESS: CODE: 403 STATUS: 403 Forbidden CONTENT:!DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN htmlhead title403 Forbidden/title /headbody h1Forbidden/h1 pYou don't have permission to access / on this server./p hr / addressApache/2.0.46 (Red Hat) Server at www.yahoo.com Port 80/address /body/html ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: LWP help
Title: Message I believe this line: $req-content('query=libwww-perlmode=dist'); is your problem. Anyway, it's what apparently kills the script for me, particularly against yahoo (if I remove it and the proxy settings (which I don't need) it runs successfully for me). Am I correct that you listed this code off a tutorial page? It looks like this relates specifically to CPAN (since if I run it against CPAN it does work, though I do notice you changed a POST to a GET, and it's the POST that works against CPAN). I also noticed that your attached "STATFILE" indicates "forbidden", not "not found". . . I'm not sure the significance of this. . . Sam Gardner GTO Application Development Keefe, Bruyette Woods, Inc. 212-887-6753 -Original Message-From: Lasher, Brian [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 11:53 AMTo: Gardner, Sam; Perl-Win32-UsersSubject: RE: LWP help Lwp_example.pl is script. STATFILE is output. I changed the "proxy server" info to protect TI proprietary data, and changed the site that is being accessed (although result is the same). Brian Lasher Catalog DSP Product Engineering Best Practices and Yield Enhancement Team [EMAIL PROTECTED] 281-274-2913(W) 281-684-4699(C) 713-664-6240(H) 281-274-2279(F) -Original Message-From: Gardner, Sam [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 26, 2004 1:07 PMTo: Lasher, Brian; Perl-Win32-UsersSubject: RE: LWP help Kind of hard to tell, w/o seeing the script or knowing what page it is. . . Sam Gardner GTO Application Development Keefe, Bruyette Woods, Inc. 212-887-6753 -Original Message-From: Lasher, Brian [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 26, 2004 1:29 PMTo: Perl-Win32-UsersSubject: LWP help I wrote a script using the LWP module. At first I got error 500 (something about server does not exist). Realized by reading the docs that I had to define my proxy server. Not getting that error now, so I assume that fix worked. Now I'm getting error 404 (doc not found) for a site that I know is correct. Script replies the following: CODE: 404 STATUS: 404 Not Found CONTENT: !DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN" htmlhead title404 Not Found/title /headbody h1Not Found/h1 pThe requested URL /04-05RD.txt was not found on this server./p hr / /body/html Anyone seen this? Is there something people can do to prevent LWP from pulling data from their server? Is there something I'm missing? -brian Brian Lasher Catalog DSP Product Engineering Best Practices and Yield Enhancement Team [EMAIL PROTECTED] 281-274-2913(W) 281-684-4699(C) 713-664-6240(H) 281-274-2279(F) ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: LWP help
Title: Message Kind of hard to tell, w/o seeing the script or knowing what page it is. . . Sam Gardner GTO Application Development Keefe, Bruyette Woods, Inc. 212-887-6753 -Original Message-From: Lasher, Brian [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 26, 2004 1:29 PMTo: Perl-Win32-UsersSubject: LWP help I wrote a script using the LWP module. At first I got error 500 (something about server does not exist). Realized by reading the docs that I had to define my proxy server. Not getting that error now, so I assume that fix worked. Now I'm getting error 404 (doc not found) for a site that I know is correct. Script replies the following: CODE: 404 STATUS: 404 Not Found CONTENT: !DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN" htmlhead title404 Not Found/title /headbody h1Not Found/h1 pThe requested URL /04-05RD.txt was not found on this server./p hr / /body/html Anyone seen this? Is there something people can do to prevent LWP from pulling data from their server? Is there something I'm missing? -brian Brian Lasher Catalog DSP Product Engineering Best Practices and Yield Enhancement Team [EMAIL PROTECTED] 281-274-2913(W) 281-684-4699(C) 713-664-6240(H) 281-274-2279(F) ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs