我正在尝试获取网页的源代码。我尝试使用LWP :: Simple,但它没有帮助。我使用ppm安装了WWW :: Selenium包,但得到了错误“未定义的子程序& main :: get_html_source在第6行调用。”
这是我使用的代码。
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use WWW::Selenium;
$url="http://www.ncbi.nlm.nih.gov/pubmed/25582922";
$out = getHtmlSource($url) or die "could not get the url $url \n";
open(file, ">testing_ncbi.txt");
print file "$out\n";
任何帮助?
答案 0 :(得分:0)
使用Selenium::Remote::Driver模块并执行以下操作
use Selenium::Remote::Driver;
my $driver = Selenium::Remote::Driver->new;
$driver->get('http://www.ncbi.nlm.nih.gov/pubmed/25582922');
print $driver->get_page_source();
答案 1 :(得分:0)
您可以使用LWP::Simple
,就像这样
use strict;
use warnings;
use LWP::Simple;
my $url = 'http://www.ncbi.nlm.nih.gov/pubmed/25582922';
my $out = get $url;
open my $fh, '>', 'testing_ncbi.html' or die $!;
print $fh $out, "\n";
和testing_ncbi.html
将包含HTML源代码
我不知道您在哪里添加source-code:
,但这并不代表网址中的任何内容