python extract images into an array from a url
<p>this should extract all images from a url into an array using python</p>
<h4>python</h4>
<pre><code class="html hljs xml">from bs4 import BeautifulSoup<br />from urllib.request import urlopen<br />url = "https://www.kruxor.com/view/code/LOveX/"<br />page = urlopen(url)<br />html = page.read().decode("utf-8")<br />soup = BeautifulSoup(html, "html.parser")<br />#print(soup.gettext())<br />images = soup.findall("img")<br />print(images)<br /></code></pre>
<p>return result</p>
<p>[<img src="https://www.kruxor.com/images/change%20the%20cursor%20to%20a%20pointer%20for%20an%20element.gif"/>, <img src="https://www.kruxor.com/images/ios-14-iphone.jpg"/>]</p>
<p><strong>extract the 1st image src only rather than the full img tag</strong></p>
<p>add this instead of print(images)</p>
<h4>python</h4>
<pre><code class="html hljs xml">imagessrc = images[0]["src"];<br />print(imagessrc)</code></pre>
