는
- 잘 내가 조금 confued하고 포스팅 intail의 끝에서 갱신 참조 나는 웹 사이트에서 일부 축소판이 필요
.... 펄 코드 따지지는 비트 abracadaba을 보이는 초보자 펄 친구가되어 ;-) ... 인정해야하지만 난은 wget을 사용하려고 - 하지만 그게 나를 위해 작동하지 않습니다, 나는 어떤 필요한 렌더링 기능이 필요하기 때문에 : 나는 파일에 저장된 각 라인에 2,500 개의 URL 목록이 있습니다. 그런 다음 파일을 열어 줄을 읽은 다음 웹 사이트를 검색하고 이미지를 작은 미리보기 이미지로 저장하는 스크립트 (아래 참조)가 필요합니다. 잘 나는 웹 사이트 (2500)의 무리가 있기 때문에 결과의 명명에 대한 내 마음을 확인해야합니다.
http://www.unifr.ch/sfm
http://www.zug.phz.ch
http://www.schwyz.phz.ch
http://www.luzern.phz.ch
http://www.schwyz.phz.ch
http://www.phvs.ch
http://www.phtg.ch
http://www.phsg.ch
http://www.phsh.ch
http://www.phr.ch
http://www.hepfr.ch/
http://www.phbern.ch
지금까지 너무 좋은, 잘 난 내가 이제 다음과 같은 결과를 얻을이
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize::Firefox;
my $mech = new WWW::Mechanize::Firefox();
open my $urls, '<', 'urls.txt' or die $!;
while (<$urls>) {
chomp;
next unless /^http/i;
print "$_\n";
$mech->get($_);
my $png = $mech->content_as_png;
my $name = $_;
$name =~ s#^http://##i;
$name =~ s#/##g;
$name =~ s/\s+\z//;
$name =~ s/\A\s+//;
$name =~ s/^www\.//;
$name .= ".png";
open(my $out, '>', "/images/$name");
binmode $out;
print $out $png;
close $out;
sleep 5;
}
뭔가를하려고 생각 .... 아웃 ... 와 멀리 대는지 볼 수 있듯이 - "이미지"폴더에 저장된 이미지가 없습니다.
왜 안되나요?
출력이 나에게 ... 내가 지금 무엇을 할 수 말하고 싶은 무엇[email protected]:~> cd perl
[email protected]:~/perl> perl test_8.pl
http://www.unifr.ch/sfm
binmode() on closed filehandle $out at test_8.pl line 25, <$urls> line 2.
print() on closed filehandle $out at test_8.pl line 26, <$urls> line 2.
http://www.zug.phz.ch
binmode() on closed filehandle $out at test_8.pl line 25, <$urls> line 3.
print() on closed filehandle $out at test_8.pl line 26, <$urls> line 3.
http://www.schwyz.phz.ch
binmode() on closed filehandle $out at test_8.pl line 25, <$urls> line 4.
print() on closed filehandle $out at test_8.pl line 26, <$urls> line 4.
http://www.luzern.phz.ch
binmode() on closed filehandle $out at test_8.pl line 25, <$urls> line 5.
print() on closed filehandle $out at test_8.pl line 26, <$urls> line 5.
http://www.schwyz.phz.ch
binmode() on closed filehandle $out at test_8.pl line 25, <$urls> line 6.
print() on closed filehandle $out at test_8.pl line 26, <$urls> line 6.
http://www.phvs.ch
binmode() on closed filehandle $out at test_8.pl line 25, <$urls> line 14.
print() on closed filehandle $out at test_8.pl line 26, <$urls> line 14. http://www.pfh-gr.ch Got status code 500 at test_8.pl line 15 [email protected]:~/perl>
!?
갱신
안녕하세요 응답에 대한 내 사랑
들으 - 내가 여기에 권한 문제가 있다고 생각 .... 글쎄이이
...
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize::Firefox;
my $mech = new WWW::Mechanize::Firefox();
open my $urls, '<', 'urls.txt' or die $!;
while (<$urls>) {
chomp;
next unless /^http/i;
print "$_\n";
$mech->get($_);
my $png = $mech->content_as_png;
my $name = $_;
$name =~ s#^http://##i;
$name =~ s#/##g;
$name =~ s/\s+\z//;
$name =~ s/\A\s+//;
$name =~ s/^www\.//;
$name .= ".png";
open(my $out, '>', "/images $name")or die $!;
binmode $out;
print $out $png;
close $out;
sleep 5;
}
잘 작동하지만 - 내가 얻을 수있는 것은 test_8.pl이있는 디렉토리에 저장하는 것입니다.
권한 문제 일 것 같네요.
내가 무엇을 할 수 있습니까?
나는 이미지 디렉토리를 펄의 폴더 바깥에 둘 수 있니 ...? 아마도 나는 특별한 루트 권한이있는
perl-directory 또는 images-directory 중 하나를 만들었습니다. 을 펄 - 내가 문제를 해결하기 위해 무엇을했는지
지금까지 폴더 에 대한 사용 권한이
A- checkint했다. perl/images
b.- 루트 사용자로 명령 줄에서 스크립트를 실행합니다.
나는 allll이 얻을 수있는 폴더에 저장된 결과입니다 ...
linux-wyee:/home/martin/perl_dev/perl # ls
.directory images module_test pfh-gr.ch.png phsg.ch.png phtg.ch.png schwyz.phz.ch.png test_4.pl test_8.pl urls.txt
heilpaedagogik.phbern.ch.png luzern.phz.ch.png module_test.pl phbern.ch.png phsh.ch.png phvs.ch.png test_2.pl test_6.pl test_8.pl~ zug.phz.ch.png
hepfr.ch.png ma-shp.luzern.phz.ch.png open-local-file.pl phr.ch.png ph-solothurn.ch.png .png test_3.pl test_7.pl unifr.chsfm.png
linux-wyee:/home/martin/perl_dev/perl #
이미지 폴더 내가이 이미지가 펄 디렉토리 그것에 문자열 경로 이름을 지정하는 방법
외부 폴더를 만들
sould을 할 수있는
비어 있습니다 .. ?!
친애하는 친구 - 우리는 여기서 만원입니다. - 저는 꽤 확신합니다. 아마 이것은 허가 문제 일뿐입니다. 그러나 그것을 해결하는 방법!?
아마도 내가 완전히 새로운 디렉토리에 모든 testfile을 만들어야합니다. 뿌리가 아니라 일반 사용자로서!? 너 뭐라구!?
'open (my $ out, '>', "/ images/$ name") 문은 문제 해결을 위해'$ die '를 추가하지 못했습니다. – Melioratus
가능한 복제본 [perl-mechanize가 여러 가지 디버깅 시도를 시작했습니다.] (http://stackoverflow.com/questions/9656892/perl-mechanize-runs-into-limitations-several-debugging-attempts-started) –
안녕하세요. .- 당신이 맞다는 것을 짐작하십시오. – zero