Advertisement
adrianmak

Untitled

Jan 30th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.chrome.options import Options
  3. from selenium.webdriver.common.keys import Keys
  4. from bs4 import BeautifulSoup
  5. import urllib.request
  6. import requests
  7. import time
  8. import shutil
  9. import os
  10.  
  11.  
  12. options = Options()
  13. # options.add_argument('--headless')
  14. # options.add_argument('--log-level=3')
  15. driver = webdriver.Chrome(options=options)
  16. driver.implicitly_wait(30)
  17.  
  18. title = "https://ec.sod.co.jp/prime/videos/?id=STARS-206"
  19. driver.get(title)
  20. ask_button = driver.find_element_by_css_selector('.enter a')
  21. ask_button.click()
  22.  
  23. time.sleep(5)
  24.  
  25. s = requests.session()
  26. for cookie in driver.get_cookies():
  27.     c = {cookie['name']: cookie['value']}
  28.     s.cookies.update(c)
  29. imgurl = 'https://dy43ylo5q3vt8.cloudfront.net/_pics/202002/stars_206/stars_206_l.jpg'
  30. response = requests.get(imgurl, stream=True)
  31. with open("test.jpg", 'wb') as out_file:
  32.     shutil.copyfileobj(response.raw, out_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement