I would want to extract the picture of the day from the following webpage https://apod.nasa.gov/apod/astropix.html using beautiful soup.
Could someone help me out with the code?
Thanks in advance!
I would want to extract the picture of the day from the following webpage https://apod.nasa.gov/apod/astropix.html using beautiful soup.
Could someone help me out with the code?
Thanks in advance!
install
pip install --upgrade beautifulsoup4
pip install --upgrade html5lib
Then to get the img src url you can do this.
from bs4 import BeautifulSoup
import requests
data = requests.get("https://apod.nasa.gov/apod/astropix.html").content
soup = BeautifulSoup(data)
img = soup.findAll("img")[0] # this link has only one image
src = "https://apod.nasa.gov"+img.attrs.get("src")
Remember dont ask to write code for you. first try and show us your effrot. This should be your last question like this.
To download the image you can check this answer