擅长:python、mysql、java
<p>尝试对图像URL创建另一个<code>requests.get()</code>,并将<code>content</code>保存到文件中</p>
<pre><code>from bs4 import BeautifulSoup
import requests
URL = "https://multco.us/health/staying-healthy/winter-wood-burning-restrictions"
soup = BeautifulSoup(requests.get(URL).content, "lxml")
img_link = soup.find("div", class_="field-body").h2.img.attrs["src"].split("?")[0]
img = requests.get(img_link)
with open("image.jpg", "wb") as f:
f.write(img.content)
</code></pre>