Alir3z4 / Alir3z4/html2text

Sometimes img src can be in attrs "data-src" instead of "src"

未关闭
#350 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
2.2k
派生
296
PR 合并指标
30 天内没有已合并 PR

描述


- html2text version: 2020.1.16
- Python version: 3.8.5

example url: [https://jingyan.baidu.com/article/4dc40848741808c8d946f18a.html](https://jingyan.baidu.com/article/4dc40848741808c8d946f18a.html) or WeChat articles.

I can not get all the images in such html. So I manually change the code of my local installed html2text and it works.

```python
# original code in __init__.py: function handle_tag()
if tag == "img" and start and not self.ignore_images:
if "src" in attrs:
assert attrs["src"] is not None
if not self.images_to_alt:
attrs["href"] = attrs["src"]
alt = attrs.get("alt") or self.default_image_alt

# If we have images_with_size, write raw html including width,
# height, and alt attributes
if self.images_as_html or (
self.images_with_size and ("width" in attrs or "height" in attrs)
):
self.o("

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。