⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test-np.px

📁 Wget很好的处理了http和ftp的下载,很值得学习的经典代码
💻 PX
字号:
#!/usr/bin/perl -wuse strict;use HTTPTest;###############################################################################my $mainpage = <<EOF;<html><head>  <title>Main Page</title></head><body>  <p>    Some text and a link to a <a href="http://localhost:8080/firstlevel/secondpage.html">second page</a>.  </p></body></html>EOFmy $secondpage = <<EOF;<html><head>  <title>Second Page</title></head><body>  <p>    Some text and a link to a <a href="http://localhost:8080/firstlevel/lowerlevel/thirdpage.html">third page</a>.  </p></body></html>EOFmy $thirdpage = <<EOF;<html><head>  <title>Third Page</title></head><body>  <p>    Some text and a link to a <a href="http://localhost:8080/higherlevelpage.html">higher level page</a>.  </p></body></html>EOFmy $fourthpage = <<EOF;<html><head>  <title>Fourth Page</title></head><body>  <p>    This page is only linked by the higher level page. Therefore, it should not    be downloaded.   </p></body></html>EOFmy $higherlevelpage = <<EOF;<html><head>  <title>Higher Level Page</title></head><body>  <p>    This page is on a higher level in the URL path hierarchy. Therefore, it    should not be downloaded. Wget should not visit the following link to a     <a href="http://localhost:8080/firstlevel/fourthpage.html">fourth page</a>.  </p></body></html>EOF# code, msg, headers, contentmy %urls = (    '/firstlevel/index.html' => {        code => "200",        msg => "Dontcare",        headers => {            "Content-type" => "text/html",        },        content => $mainpage,    },    '/firstlevel/secondpage.html' => {        code => "200",        msg => "Dontcare",        headers => {            "Content-type" => "text/html",        },        content => $secondpage,    },    '/firstlevel/lowerlevel/thirdpage.html' => {        code => "200",        msg => "Dontcare",        headers => {            "Content-type" => "text/html",        },        content => $thirdpage,    },    '/firstlevel/fourthpage.html' => {        code => "200",        msg => "Dontcare",        headers => {            "Content-type" => "text/plain",        },        content => $fourthpage,    },    '/higherlevelpage.html' => {        code => "200",        msg => "Dontcare",        headers => {            "Content-type" => "text/plain",        },        content => $higherlevelpage,    },);my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:8080/firstlevel/";my $expected_error_code = 0;my %expected_downloaded_files = (    'firstlevel/index.html' => {        content => $mainpage,    },    'firstlevel/secondpage.html' => {        content => $secondpage,    },    'firstlevel/lowerlevel/thirdpage.html' => {        content => $thirdpage,    },);###############################################################################my $the_test = HTTPTest->new (name => "Test-np",                              input => \%urls,                               cmdline => $cmdline,                               errcode => $expected_error_code,                               output => \%expected_downloaded_files);exit $the_test->run();# vim: et ts=4 sw=4

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -