Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.keys import Keys
  3. from selenium.common.exceptions import TimeoutException
  4. from selenium.common.exceptions import NoSuchElementException
  5. from selenium.webdriver.common.by import By
  6. import selenium.webdriver.support.ui as ui
  7. import selenium.webdriver.support.expected_conditions as EC
  8. import os
  9. import time
  10. import sys
  11. #import configparser
  12.  
  13. #Nastavení Driveru
  14. options = webdriver.ChromeOptions()
  15. options.add_argument('--ignore-certificate-errors')
  16. options.add_argument('--ignore-sll-errors')
  17. options.add_argument('log-level=3') #Ignorovat výpis erorů
  18. options.add_argument("--disable-infobars") #DISABLE: Chrome is being controlled by automated test software
  19. options.add_argument('headless') #Bez Hlavičky
  20. dir_path = os.path.dirname(os.path.realpath(__file__))
  21. chromedriver = "/chromedriver"
  22. os.environ["webdriver.chrome.driver"] = chromedriver
  23. driver = webdriver.Chrome(chrome_options=options)
  24. os.system('cls')
  25. sys.tracebacklimit = 0
  26.  
  27. i=10060
  28.  
  29.  
  30. while i < 110000:
  31. i += 1
  32. urlwhile = "https://www.sledujfilmy.online/web/film/{0}".format(i)
  33. driver.get(urlwhile)
  34. try:
  35. film_url = driver.find_element_by_xpath('//*[@id="iframe-box"]').get_attribute('src')
  36. except NoSuchElementException:
  37. continue
  38. film_obrazek = "https://www.sledujfilmy.online/images/posters/{0}.jpg".format(i)
  39. film_jmeno = driver.find_element_by_xpath('/html/body/div[6]/div/div[1]/h3').text
  40. film_zanr = driver.find_element_by_xpath('/html/body/div[6]/div/div[1]/p').text
  41.  
  42. #print(film_url, film_obrazek, film_popis, film_jmeno, film_zanr)
  43.  
  44. file = open("sledujufilmyonline.txt","a", encoding='utf-8')
  45. file.write('{')
  46. file.write('"name": "{0}",'.format(film_jmeno))
  47. file.write('"genre": "{0}",'.format(film_zanr))
  48. file.write('"thumb": "{0}",'.format(film_obrazek))
  49. file.write('"video": "{0}"'.format(film_url))
  50. file.write('},')
  51. file.write('\n')
  52. file.close()
  53. print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement