【发布时间】:2021-01-06 00:59:06
【问题描述】:
url = 'http://www.xxx'
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html, 'html.parser')
s1 = soup.find_all(id="contents")
print(s1, "\n")
find_all 的输出:
[<div id="contents" style="width:1000px;padding:10px 0;overflow:hidden;"><table style="margin:0;width:1000px;overflow:hidden;" width="980">
<tr><td style="text-align:center;">
<img src="http://xxx/shop/data/editor/2020090302-01.jpg"/></td></tr></table>
</div>]
如何从结果中获取img 标签的src?
我有什么方法可以获取 url 而不是 id="contents" 选项吗?
我只想要结果中的 URL。
【问题讨论】:
-
你能添加你要报废的确切网址吗?
-
cobaro.co.kr/shop/goods/… 我们开始!从上面的网址。我想要的是获取图片的网址!这是 [cobaro.co.kr/shop/data/editor/2020090302-01.jpg"/></…
-
请记住,要中断文本行,您可以在行尾使用两个空格。不建议无缘无故地打开一个新段落(文本行之间有一个换行符)——这会占用页面太多空间。
标签: python python-3.x beautifulsoup bs4dash