Create Great Parser - Extract Relevant Text From HTML/Blogs

前端 未结 2 921
挽巷
挽巷 2020-12-23 12:26

I\'m trying to create a generalized HTML parser that works well on Blog Posts. I want to point my parser at the specific entrie\'s URL and get back clean text of the post it

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 12:59

    Boy, do I have the perfect solution for you.

    Arc90's readability algorithm does exactly this. Given HTML content, it picks out the content of the main blog post text, ignoring headers, footers, navigation, etc.

    Here are implementations in:

    • JavaScript
    • Perl
    • PHP
    • Python
    • Ruby
    • C#

    I'll be releasing a Perl port to CPAN in a couple of days. Done.

    Hope this helps!

提交回复
热议问题