LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-05-2014, 12:36 AM   #1
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 291

Rep: Reputation: Disabled
perl mechanize question


i am trying to download files from the internet like so

Code:
open FILE, "<Album_ID_list", or die "Can't open file: $!";

my @lines = <FILE>;

my $mech = WWW::Mechanize->new( );

foreach my $i ( @lines ) {
$mech->get( "https://graph.facebook.com/$i/photos?access_token=$token_string", ':content_file' => "Photostream_Album_$i" );
}
but receive this error

Code:
Error GETing https://graph.facebook.com/678987900...syEyt4IZCJoZD: Not Found at test4.pl line 44.
If i am not mistaken, that %0A before /photos? is a new line char. What am I doing wrong??
.

Last edited by amboxer21; 01-05-2014 at 12:43 AM.
 
Old 01-05-2014, 05:58 PM   #2
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
I'd probably have to get into more detail than you've provided to be sure, but my first instinct is that maybe chomp should be used on the input lines from the file, before using them as part of the URL.

Last edited by rigor; 01-05-2014 at 06:33 PM.
 
1 members found this post helpful.
Old 01-06-2014, 03:02 PM   #3
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 291

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rigor View Post
I'd probably have to get into more detail than you've provided to be sure, but my first instinct is that maybe chomp should be used on the input lines from the file, before using them as part of the URL.
Sorry That I did not provide enough information. I have solved the problem. You were correct with the missing chomp. I also used 3 arg open lexical file handles instead of the old bareword style.

Code:
open my $in_fh, '<', "Album_ID_list"
   or die "Can't open file: $!";

my @lines = <$in_fh>;

foreach my $i ( @lines ) {
   chomp( $i );
   system( "wget https://graph.facebook.com/$i/photos?access_token=$token_string -O Photostream_Album_$i" );
 }

close($in_fh);
Thanks for your response and time I appreciate it!
 
  


Reply

Tags
char, character, mechanize, new line, perl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
saving results of a perl Mechanize::FireFox task - HowTo sayhello_to_the_world Programming 3 07-01-2013 01:29 AM
storing the results of a perl::mechanize script sayhello_to_the_world Programming 1 05-24-2013 12:49 AM
Perl's "www::mechanize" module fails to upload file having large size paragkalra Programming 2 10-24-2008 08:21 AM
Using WWW::Mechanize in perl nigel_mark2004 Programming 3 04-06-2006 07:00 PM
WWW::Mechanize dexter_modem Programming 0 06-23-2003 04:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration