input: Write a function to scrape photos and captions from a given website. The function should take a URL as input and return a list of tuples where each tuple contains the photo URL and its corresponding caption. If the caption is missing, it should return an empty string for the caption. If the website is not accessible, it should raise an HTTPError.
  assert scrape_photos_and_captions('https://example.com/webpage')==[('https://example.com/photo1.jpg', 'Caption 1'), ('https://example.com/photo2.jpg', '')]
  assert scrape_photos_and_captions('https://invalid-url.com')
  
  from bs4 import BeautifulSoup
  import requests
  
  def scrape_photos_and_captions(url):
      # Get the HTML source code
      try:
          req = requests.get(url)
          req.raise_for_status()
          html = req.text
      except requests.exceptions.HTTPError as e:
          raise
  
      # Parse HTML source and extract photo and caption
      soup = BeautifulSoup(html, features='lxml')
      image_divs = soup.find_all('div', {'class': 'image-gallery__image'})
      results = []
  
      for image_div in image_divs:
          figure = image_div.find('figure')
          src = figure.find('img')['src']
          caption = figure.find('figcaption')
          if caption:
              results.append((src, caption.text))
          else:
              results.append((src, ''))
  
      return results
output: from bs4 import BeautifulSoup
  import requests
  
  def scrape_photos_and_captions(url):
      try:
          req = requests.get(url)
          req.raise_for_status()
          html = req.text
      except requests.exceptions.HTTPError as e:
          raise
  
      soup = BeautifulSoup(html, features='lxml')
      image_divs = soup.find_all('div', {'class': 'image-gallery__image'})
      results = []
  
      for image_div in image_divs:
          figure = image_div.find('figure')
          src = figure.find('img')['src']
          caption = figure.find('figcaption')
          if caption:
              results.append((src, caption.text))
          else:
              results.append((src, ''))
  
      return results