Download files with Perl

后端 未结 2 1653
南笙
南笙 2021-01-15 16:23

I have updated my code to look like this. When I run it though it says it cannot find the specified link. Also what is a good way to test that it is indeed connecting to the

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-15 17:08

    Basically, you need to fetch the page, parse it to get the URL, and then download the file.

    Personally, I'd use HTML::TreeBuilder::XPath, write a quick XPath expression to go straight to the correct href attribute node, and then plug that into LWP.

    use HTML::TreeBuilder::XPath;
    my $tree = HTML::TreeBuilder::XPath->new;
    $tree->parse({put page content here});
    foreach($tree->findnodes({put xpath expression here}){
        {download the file}
    }
    

提交回复
热议问题