推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yuhu96
V2EX  ›  Python

在学爬虫中,有什么比较好的解析 markdown 类型文章的方案呢?

  •  
  •   yuhu96 · Jan 29, 2020 · 2937 views
    This topic created in 2320 days ago, the information mentioned may be changed or developed.

    大家好,我想定期爬一些我关注的专栏的文章。这类文章通常是经过 markdown 发布的,有比较规整的格式,内容除了正文之外,还有不同的格式,比如字体大小,加重之类,贴图还附有图床链接,还有代码块之类比较不好处理的地方。

    我的爬虫很简单基本就是 request beautifulsoup 这一套东西,没什么花的,希望就是能把这些文章原封不动给抓到写到的 markdown 文件里,方便本地阅读。

    我通过爬虫解析文章页面之后往往不方便提取这些东西。比如正文有很多标签,可以直接 soup.article.gettext 的方法获取,但是图片连接也在一些标签里,就不太好提取,也实在是懒得写正则之类的麻烦东西,请问有没有比较好的方法或方案呢?

    1 replies    2020-01-29 22:32:43 +08:00
    RedisMasterNode
        1
    RedisMasterNode  
       Jan 29, 2020
    https://pypi.org/project/html2markdown/
    随手搜的 不知道是否能够满足你的需求,个人感觉把你的问题转成英文在 Google 上搜索会比较快
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2751 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 02:23 · PVG 10:23 · LAX 19:23 · JFK 22:23
    ♥ Do have faith in what you're doing.