473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

downloading from webpage

Hi,

Can someone please help me with this. i am new to using modules and trying to run this script. but it displays the following message:
Can't connect to www.search.cpan.org:80 (Bad hostname 'www.search.cpan.org')

here is the script

Expand|Select|Wrap|Line Numbers
  1. # Create a user agent object
  2.   use LWP::UserAgent;
  3. use HTTP::Headers;
  4.   $ua = LWP::UserAgent->new;
  5.   my $newagent = 'search_rfc/1.0('.$ua->agent.')';
  6.   $ua->agent($newagent);
  7.  
  8.   # Create a request
  9.   my $req = HTTP::Request->new(POST =>'http://www.search.cpan.org/search');
  10.   $req->content_type('application/x-www-form-urlencoded');
  11.   $req->content('query=libwww-perl&mode=dist' );
  12.  
  13.   # Pass request to the user agent and get a response back
  14.   my $res = $ua->request($req);
  15.  
  16.   # Check the outcome of the response
  17.   die $res->message unless $res->is_success;
  18.   print "echo $res->as_string\n";
  19.  
Thank you
john
Oct 8 '07 #1
8 1563
KevinADC
4,059 Expert 2GB
John,

http://www.search.cpan.org/search

there should be no ' www ' in the above url
Oct 8 '07 #2
John,

http://www.search.cpan.org/search

there should be no ' www ' in the above url
Kevin,

Thanks for your reply, but i have everything from cpan site what i need, i just am not getting the output. it keeps on displaying "Can't connect to search.cpan.org:80". whats with the port 80? please help me.

thank you
johnperl
Oct 9 '07 #3
numberwhun
3,509 Expert Mod 2GB
Kevin,

Thanks for your reply, but i have everything from cpan site what i need, i just am not getting the output. it keeps on displaying "Can't connect to search.cpan.org:80". whats with the port 80? please help me.

thank you
johnperl
What are you trying to do, download all of the modules from CPAN?

Regards,

Jeff
Oct 9 '07 #4
What are you trying to do, download all of the modules from CPAN?

Regards,

Jeff
Jeff

No no that's just an example. if it works than i will apply it. well here is the site from which i just need tha month data. http://stats.world-aluminium.org/iai...er.asp?form=11 could you please help me with this.

thank you
Oct 9 '07 #5
eWish
971 Expert 512MB
Do you have any other code that you have written? Currently it only looks for the website. Do you have any code to get the data from the page that the LWP module is returning?

Have you looked into using an HTML Parser to parse the html and gather the data you wish to keep?

One way you can do this is to use the following modules:

WWW:Mechanize (to get the content of the page and save it in one step. The FAQ section can be helpful)
HTML::Parser or HTML::TokeParser (to filter out the data you want form an HTML document.)
Oct 10 '07 #6
Do you have any other code that you have written? Currently it only looks for the website. Do you have any code to get the data from the page that the LWP module is returning?

Have you looked into using an HTML Parser to parse the html and gather the data you wish to keep?

One way you can do this is to use the following modules:

WWW:Mechanize (to get the content of the page and save it in one step. The FAQ section can be helpful)
HTML::Parser or HTML::TokeParser (to filter out the data you want form an HTML document.)
Hi,
I tried all the modules the problem is with the proxy setting we have a setting of webproxy. the script works fine for internal network site but doe not work for any other site due to proxy setting. the only thing is how can i set the proxy. our proxy setting has to be webproxy.
below is the script,

Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl_5.6.1 -w
  2.  
  3. $env_proxy = $ENV{"env_proxy"};
  4.  
  5. use LWP::UserAgent;
  6.   $ua = LWP::UserAgent->new;
  7.   $ua->env_proxy; # initialize from environment variables
  8.   # or
  9.   $ua->proxy(ftp  => 'http://proxy.bip.com');
  10.   $ua->proxy(webproxy => "$env_proxy");
  11.   $ua->no_proxy(qw(no se fi));
  12.  
  13.   my $req = HTTP::Request->new(GET => "http://bip/");
  14.   print $ua->request($req)->as_string;
  15.  
thank you
Oct 10 '07 #7
numberwhun
3,509 Expert Mod 2GB
Hi,
I tried all the modules the problem is with the proxy setting we have a setting of webproxy. the script works fine for internal network site but doe not work for any other site due to proxy setting. the only thing is how can i set the proxy. our proxy setting has to be webproxy.
below is the script,

Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/perl_5.6.1 -w
  2.  
  3. $env_proxy = $ENV{"env_proxy"};
  4.  
  5. use LWP::UserAgent;
  6.   $ua = LWP::UserAgent->new;
  7.   $ua->env_proxy; # initialize from environment variables
  8.   # or
  9.   $ua->proxy(ftp  => 'http://proxy.bip.com');
  10.   $ua->proxy(webproxy => "$env_proxy");
  11.   $ua->no_proxy(qw(no se fi));
  12.  
  13.   my $req = HTTP::Request->new(GET => "http://bip/");
  14.   print $ua->request($req)->as_string;
  15.  
thank you
You have posted code into the forum without using proper code tags. It is best practice here on TSDN to wrap all code posted into the forum in code tags.

Code tags start with [code] and end with [/code]. If you need an example other than this one, the please refer to the REPLY GUIDELINES (or POSTING GUIDELINES if you are starting a discussion) to the right of the Message window. You will find the examples and suggestions for posting there.

In addition, you can also add the language to your code tags. Here is an example:

[code=perl]
<some code>
[/code]

Please know that I have fixed your posts above to include the proper code tags. Please be sure and use code tags in all of your future posts here on TSDN.

- Moderator
Oct 10 '07 #8
eWish
971 Expert 512MB
Try reading the FAQ page I linked to above for WWW::Mechanize module. It will show you how to deal with a proxy server.
Oct 11 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: David Rasmussen | last post by:
Very basic: What is the easiest way in php to download the source code (HTML etc.) of a given URL (say, http://www.google.com) and parse this code for certain patterns? I guess my question...
4
by: Luke StClair | last post by:
Only marginally belonging in this newsgroup... but oh well. I've just started writing in python, and I want to make the files available on the web. So I did the standard <a...
4
by: Jeff Cooper | last post by:
There must be something I'm missing. No else else seems to have this issue -- at least I don't see it mentioned anywhere. (Also, my appologies for my earlier posts in which I mistakenly referred...
2
by: Matt Mercer | last post by:
Hi all, I have a database application (asp .net vb) where I need to upload and download files to a SQL database. I am not going to store the files in the database...just the file name. All the...
23
by: Doug van Vianen | last post by:
Hi, Is there some way in JavaScript to stop the downloading of pictures from a web page? Thank you. Doug van Vianen
1
by: Eggy | last post by:
Hi. I have an application that should download files from internet. The problem is the protocol is HTTPS. So I have a System.Windows.Forms.WebBrowser which allows the user to log in to the HTTPS...
1
by: Hexman | last post by:
Code below ---- I'm trying to save some specific web pages to disk as text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a...
7
by: Steve | last post by:
Hello, I am a beginner/intermediate c++ coder. I have a program that I am writing and would like to be able to distribute to some of my friends. The problem with this is that the data files...
0
by: =?Utf-8?B?am5ubA==?= | last post by:
Both of my computers cannot even start downloading the software from either the ideawins.com site or the microsoft site. They both say: "Internet Explorer cannot display webpage". I have...
1
by: JRussell | last post by:
Hi, I am trying to download sql database through asp on my webpage and I keep getting weird outcomes in Excel. I have had to put in <char10> and <char13> into my sql data to have it display...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.