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: Intermediate:
how to import a URL???

 



johnny241088
Novice

Feb 15, 2013, 4:25 PM

Post #1 of 7 (1090 views)
how to import a URL??? Can't Post

I try tu read in a URL with this code

Code
use strict; 
use warnings;
use LWP::Simple;

my $local = "pcw.txt";
print "Bitte URL eingeben\n"; #Liest nur die Startseite ein
my $url = <STDIN>;

my $page = get($url) or die "failed!\n";

open my $out, '>', $local or die "Cannot open $local for output: $!\n";
print $out $page;
close $out;


but my problem is i receive (not become) ;) only the source code of the starting site and not of the hole url, but why???


(This post was edited by johnny241088 on Feb 16, 2013, 12:18 PM)


Laurent_R
Veteran / Moderator

Feb 16, 2013, 1:32 AM

Post #2 of 7 (1084 views)
Re: [johnny241088] how to import a URL??? [In reply to] Can't Post


In Reply To

but my problem is i became only the source code of the starting site and not of the hole url, but why???


Hi Johnny,

to become = werden (in German)
bekommen = to receive, to obtain, to get

;-)


lightspd
Novice

Feb 16, 2013, 9:01 PM

Post #3 of 7 (1065 views)
Re: [johnny241088] how to import a URL??? [In reply to] Can't Post

What exactly are you trying to get from the url?

From LWP::Simple:

The get() function will fetch the document identified by the given URL and return it. It returns undef if it fails

Which should pull the source code of the URL as I understand it.


johnny241088
Novice

Feb 17, 2013, 6:30 AM

Post #4 of 7 (1058 views)
Re: [lightspd] how to import a URL??? [In reply to] Can't Post

i want the source code of this url for example:
http://www.cs-manager.com/csm/?p=game_games&s=report&t=pcw&g=79775462

but the hole time i receive only the code of this url:
http://www.cs-manager.com

i know this script give me only the source code of the starting site but maybe u have a idea how i can get the code of the hole url.
regards jOhnny


(This post was edited by johnny241088 on Feb 17, 2013, 7:10 AM)


Laurent_R
Veteran / Moderator

Feb 17, 2013, 7:48 AM

Post #5 of 7 (1052 views)
Re: [johnny241088] how to import a URL??? [In reply to] Can't Post

If I go on this URL http://www.cs-manager.com/csm/?p=game_games&s=report&t=pcw&g=79775462 with my Internet browser, I also end up there: http://www.cs-manager.com.

Your problem might have nothing to do with perl.


johnny241088
Novice

Feb 17, 2013, 8:10 AM

Post #6 of 7 (1048 views)
Re: [Laurent_R] how to import a URL??? [In reply to] Can't Post

yes thats the point. you must be logged in to go foward to the other url.
is it possible to log in with a perl script to get the url ( http://www.cs-manager.com/csm/?p=game_games&s=report&t=pcw&g=79775462)???


lightspd
Novice

Feb 17, 2013, 8:39 AM

Post #7 of 7 (1045 views)
Re: [johnny241088] how to import a URL??? [In reply to] Can't Post

I would look into LWP::useragent or WWW:Mechanize for the login part.

http://search.cpan.org/~gaas/libwww-perl-6.04/lib/LWP/UserAgent.pm

http://search.cpan.org/~jesse/WWW-Mechanize-1.72/lib/WWW/Mechanize.pm#SYNOPSIS

 
 


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

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