Having trouble extracting the url from the background picture on this website. This picture refreshes every 5 minutes, changing the url so as far as I am aware I am forced to use this website, refresh every 5 minutes and grab this url. Ultimately, I am trying to grab this image every 5 minutes to create a video. I am able to navigate to the Div that I need, but when I am trying to split the string, I get errors about it not being a string. when is use print(type(divreq)) I get a bs4.element.Tag.
import time
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
url = "https://camera.deckchair.com/emporium-hotel-brisbane-australia"
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(options=options)
driver.get(url)
time.sleep(3)
page = driver.page_source
driver.quit()
soup = BeautifulSoup(page, 'html.parser')
divreq = soup.find('div',class_='image')
print(divreq)
my output is:
<div _ngcontent-ptg-1="" class="image" style='background-image: url("//api.deckchair.com/v1/viewer/image/610a5f61a95c310001bf67ba?width=1280&height=720&resizeMode=fill&gravity=Auto&quality=90&panelMode=false&format=jpg"); background-position: 50% 50%;'> </div>
The information I am trying to get is:
api.deckchair.com/v1/viewer/image/610a5f61a95c310001bf67ba
with the 610a5f61a95c310001bf67ba changing every 5 mintues.