我应该使用HTML :: Parser还是XML :: Parser提取和替换文本? [英] Should I use HTML::Parser or XML::Parser to extract and replace text?

查看:72
本文介绍了我应该使用HTML :: Parser还是XML :: Parser提取和替换文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从HTML/XHTML文档中提取所有纯文本并进行分析/修改,然后在需要时进行替换.我可以使用 HTML :: Parser 还是将它设为 XML :: Parser ?

I am looking at being able to extract all plain text and analyse/amend from HTML/XHTML document and then replace if needed. Can I do this using HTML::Parser or should it be XML::Parser?

有没有人知道的好示范?

Are there any good demonstrations that anyone knows of?

推荐答案

您还应该查看网站:: Scraper .
我发现此模块比HTML :: Parser模块更容易,但是如果您熟悉XPath,它会有所帮助.
根据实际页面的不同,HTML的解析是非常不可预测的-就像pdf显示而不是面向数据的.

You should also look at Web::Scraper.
I find this module easier than the HTML::Parser modules, but it helps if your are familiar with XPath.
Parsing of HTML is very unpredictable depending on the actual pages - it is like pdf-display and not data-oriented.

这篇关于我应该使用HTML :: Parser还是XML :: Parser提取和替换文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆