title: Instagram Scraping: How would I save stories?
body: <p>I'm am currently coding an Instagram story scraper for fun because why not and I've gotten to the point where I need to download the story files but the sources to the images / videos aren't in the HTML code. Is there a process I can use to get the images to load into the browser's urls? Or is there some other more efficient way of doing this?</p>
  
  <p>I've tried finding the source of the images but they don't exist since its loaded outside of the HTML.</p>
  
  <pre><code>from selenium import webdriver
  import selenium
  import time
  
  story_page = "https://www.instagram.com/stories" + "/" + account_purging
  
  driver = webdriver.Firefox()
  # Login
  driver.get("https://www.instagram.com/accounts/login/")
  time.sleep(1)
  driver.find_element_by_name('username').send_keys(myusername)
  driver.find_element_by_name('password').send_keys(mypassword)
  time.sleep(2)
  # Click Login
  try:
      driver.find_element_by_xpath("/html/body/span/section/main/div/article/div/div[1]/div/form/div[4]/button/div").click()
  except Exception as e:
      print(e)
      driver.find_element_by_xpath("/html/body/span/section/main/div/article/div/div[1]/div/form/div[5]/button").click()
  
  time.sleep(2)
  
  # Go To stories
  
  driver.get(story_page)
  time.sleep(1)
  
  
  #Download stories seen
  img = driver.find_element_by_xpath("/html/body/span/section/div/div/section/div[2]/div[4]")
  src = img.get_attribute('src')
  print(src)
  </code></pre>
  
  <p>The code returns as None since there isn't a source link directly in plain sight. Using the NETWORK button in source editor I'm able to find it manually but I know there's a more efficient way.</p>
  
  <p>Edit:
  Here is an example of a story url. Maybe there's a way using this?</p>
  
  <p><code>https://scontent-ort2-1.cdninstagram.com/vp/b83f011616e4bb20c52cbc21ca17213f/5CA3832C/t50.12441-16/56522959_2235298350017959_2397626998618515587_n.mp4?_nc_ht=scontent-ort2-1.cdninstagram.com</code></p>