或
HTML5 其他人使用
; >
,有些使用
>
和其他根本不使用。因此,标签的组合以及网站的布局都有不同的组合。
Evernote 的 Web Clipper 插件 或 宣布插件仅获取相关文章/帖子/内容部分页面的?这是 Evernote 插件的屏幕截图:
无论您访问哪个网站,它都与其他布局完全不同,这些总是能够让您获得页面的文章/帖子/内容部分。
每个网站都有不同的布局,有些有侧边栏,有些没有,不同的标签,对于主/文章/内容部分,有些使用
或
HTML5 其他人使用
; >
,有些使用
>
和其他根本不使用。因此,标签的组合以及网站的布局都有不同的组合。
任何人都可以建议通过 Javascript 或 PHP 获取 main 文章/帖子/内容的解决方案吗?
How does Evernote's Web Clipper plugin or Announcify plugin only get relevant article/post/content part of the page? Here is an screenshot from evernote plugin:
No matter which website you visit which is completely different from other layout wises, these are always able to get you article/post/content part of the page.
Each website has different layouts, some have sidebar, some don't, different tags, for main/article/content part, some use <article>
or <section>
of HTML5 others use <h1> > <p>
, some use <h2> > <p>
and others don't use at all. So there are different combination of tags as well as layouts of websites.
Can anyone suggest a solution to getting main article/post/content please via Javascript or PHP?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您可以进行简单的 DOM 解析并搜索包含更多文本的
和
(文本!不是 HTML 代码!< /强>)。然而,无论您选择哪种智能方法来确定内容的位置,您都应该从 DOM 解析开始,所以让我们看一下 DOM 解析 PHP 库。
无论如何,你可以从这里开始:
看起来相当不错,如果你想写一些自己的东西,并给出技术解释。
You can do a simple DOM parsing and search for the
<div>
s and<p>
s containing more text (text! not HTML code!). However, regardless of the intelligent method you will choose for determining where the content is, you should start from DOM parsing, so let's have a look at DOM parsing PHP libraries.Anyway, you can start from this:
Looks quite good, and gives technical explanations if you want to write something of your own.
大多数博客引擎都会为该 div 提供“内容”的 id。
Most blog engines give that div an id of 'content'.