furas

Python - Selenium - Netflix

Apr 29th, 2017
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import selenium
  4. import selenium.webdriver
  5.  
  6. # PhantomJS
  7. #
  8. # - install nodejs from https://nodejs.org
  9. # - install phantomjs
  10. #     npm -g install phantomjs-prebuilt
  11.  
  12. driver = selenium.webdriver.PhantomJS()
  13. driver.set_window_size(1900, 1200)
  14. #driver.implicitly_wait(10) # seconds
  15.  
  16. # Chrome:  
  17. #
  18. # - install chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
  19.  
  20. #driver = selenium.webdriver.Chrome()
  21.  
  22. # Firefox:
  23. #
  24. # - install geckodriver: https://github.com/mozilla/geckodriver/releases
  25.  
  26. #driver = selenium.webdriver.Firefox()
  27.  
  28. login = input('login: ')
  29. password = input('password: ')
  30.  
  31. # --- login ---
  32.  
  33. print('Login...')
  34.  
  35. driver.get('https://www.netflix.com/mx-en/login')
  36.  
  37. x = driver.find_element_by_name('email')
  38. x.send_keys(login)
  39.  
  40. x = driver.find_element_by_name('password')
  41. x.send_keys(password)
  42.  
  43. x = driver.find_element_by_tag_name('button')
  44. x.click()
  45.  
  46. # --- payment ---
  47.  
  48. print('Payment...')
  49.  
  50. driver.get('https://www.netflix.com/payment?action=startAction&locale=en-MX')
  51.  
  52. x = driver.find_element_by_xpath('//div[@data-reactid="28"]')
  53. x.click()
  54.  
  55. driver.save_screenshot('screenshot.png')
Add Comment
Please, Sign In to add comment