url = 'http://www.xxx'
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html, 'html.parser')
s1 = soup.find_all(id="contents")
print(s1, "\n")
The output of the 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>]
How can I get the src
of the img
tag from the results?
Do I have any way to get the url instead of the id="contents"
option?
What I just want is the URL from the result.
You can get the
src
of the img in the div like this: