我无法通过 perl get、bash 命令 GET 和 wget 下载特定页面

I could not download specific page via perl get, bash command GET and wget

我在下载页面时遇到问题,

my $url='http://www.ncbi.nlm.nih.gov/nuccore?linkname=pcassay_nucleotide&from_aid=504934,1806,1805,1674';

我可以使用浏览器浏览以下内容,但是当我在 perl 或 linux shell、

中使用 运行 bash 命令时
GET $url >OUTPUT1;  # Even it does not write anything to file "OUPUT1"

当我尝试 wget 时,它下载但不正确,我的意思是 --> <title>Error - Nucleotide - NCBI</title>。我想要包含项目的页面,但 returns 我想要一个没有项目的页面。

my $html = qx{wget --quiet --output-document=OUTPUT1 $url};

**注意:几分钟前我注意到,url在Mozilla firefox下是可以的,但是不能通过googlechrome浏览。这很奇怪,可能我的问题也与此有关。有什么想法吗?

来自 link 的代码:

my $url='http://www.ncbi.nlm.nih.gov/nuccore?linkname=pcassay_nucleotide&from_aid=504934,1806,1805,1674';


my $html = qx{wget --quiet --output-document=OUTPUT11 $url};

# wget get something, but it does not get items, it gets what I get via google chrome

`GET $url2 >OUTPUT11`; # it does not write anything to file,

好的,鉴于您的代码 - 问题几乎可以肯定是插值问题之一。因为你的 URL 中的 & 将被你生成的 shell 解释为 'background this process'。

这几乎肯定不是您想要的。为什么不在本地使用 LWP?

#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;

my $url='http://www.ncbi.nlm.nih.gov/nuccore?linkname=pcassay_nucleotide&from_aid=504934,1806,1805,1674';

my $content = get $url;

print $content;

open ( my $output_fh, '>', 'output.html' ) or die $!;
print {$output_fh} $content; 
close ( $output_fh );