用于检查网站上断链接的Perl [英] Perl for checking broken link on a website
问题描述
大家好!
我是这个论坛的新手,我希望能获得帮助来提高我的PERL技能。
>
我的目标是能够从网站创建所有损坏链接的报告。根据我的理解,PERL可以访问服务器目录并搜索htm / html文件并将其放在数组中。从这个数组我相信PERL可以搜索http://字符串和模拟以单击URL。如果网址包含无法找到网页然后创建并附加到日志文件。
我的问题是,执行此操作的最佳方法是什么以及所需的库和语法是什么?
也用于搜索htm文件在服务器上,假设我没有访问服务器目录(这不太可能),我该如何完成?如果我有权访问服务器,在PERL搜索htm之前,如何让PERL首先登录服务器?特定目录上的文件?或者我是否必须将PERL .pl文件放在服务器根目录并在那里运行?
如果有人可以提供帮助,我真的很感激。谢谢。
欢迎来到TSDN!
我建议您使用像 WWW :: Mechanize 或 LWP :: UserAgent 实现你想要的。另外,结帐 WWW: :机械化::常见问题解答。
--Kevin
您也可以查看 W3C :: LogValidator :: LinkChecker 。如果我正确阅读它将使用您的服务器日志找到损坏的链接。
--Kevin
感谢您的反馈Kevin!还有其他人吗?
我会稍后尝试发布示例代码以供您反馈,也可供其他人学习。干杯!
Hi Guys!
I am new on this forum and I am hoping that I could acquire help to improve my PERL skill.
My goal is to be able to create a report of all broken links from a website. Based from my understanding, PERL can go through to server directory and search for htm/html file and put it on an array. From this array I believe PERL can search for a "http://" string and emulate to click the URL. If the URL contains "Page cannot be found" then create and append to a log file.
My question, what is the best method to do this and what is the required library and syntax?
Also for searching the "htm" file on a server, assuming that I don''t have access to get in to server directory (which is unlikely) , how do I get this done? and if I have an access to the server how do I get PERL to login to the server first before PERL search for "htm" file on a specific directory? or do I have to put the PERL .pl file on the server root directory and run it there?
I really appreciate if someone could help. Thank you.
Welcome to TSDN!
I would suggest that you use a module like WWW::Mechanize or LWP::UserAgent to achieve that you are wanting. Also, checkout WWW::Mechanize::FAQ.
--Kevin
You might also check out W3C::LogValidator::LinkChecker . If I read it correctly it will use your server log to locate broken links.
--Kevin
Thanks for your feedback Kevin! anyone else?
I will try to post the sample code later on for your feedback and also for someone else to learn. Cheers!
这篇关于用于检查网站上断链接的Perl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!