首页 > 解决方案 > 如何使用 findall 查找所有信息

问题描述

我试图使用 findall 函数查找和打印一定数量的文本。无论如何,我似乎无法让它工作。在再次使用 findall 函数以获得我想要的内容之前,我尝试将所有信息打印并存储在一个变量中。我必须分两步完成,因为如果我直接搜索 src,我会从文档的其他区域得到其他垃圾。

这是我到目前为止所做的。

## locate a section of text containging the img source
html_img_source_and_junk = findall('</noscript>[\s]+<img[\s]+src="([^"]+)"[\s]+alt', html_source_whittakers)
print(html_img_source_and_junk)

这是我试图提取的信息文本。

没有脚本>

<图片

  src="//cdn.shopify.com/s/files/1/0274/7315/products/whi_225x225.jpg?v=1525431190"

alt="

标签: pythonhtml

解决方案


推荐阅读