Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- #sudo apt install python-selenium unzip xvfb libxi6 libgconf-2-4 default-jdk
- from selenium import webdriver
- #Start Headless
- from selenium.webdriver.chrome.options import Options
- options = Options()
- options.headless = True
- driver = webdriver.Chrome(options=options)
- #End Headless
- driver = webdriver.Chrome()
- driver.get('https://filmsbykris.com')
- source=driver.page_source
- print(source)
- search_box = driver.find_element_by_id("search")
- search_box.send_keys("Linux")
- #First Video Link
- item = driver.find_element_by_class_name("portfolio-item")
- item.click()
- #Array of elements
- videos = driver.find_elements_by_class_name("portfolio-item")
- video[4].click()
- search_box.clear()
- #list all buttons
- buttons = driver.find_elements_by_class_name("btn")
- for b in buttons:
- b.get_attribute('innerHTML')
- #Using CSS selectors
- menu_item = driver.find_elements_by_css_selector(".page-scroll")
- for i in menu_item:
- i.get_attribute('innerHTML')
- #Get link by Link Text
- links = driver.find_elements_by_partial_link_text("LBRY")
- links[0].get_attribute('innerHTML')
- links[0].get_attribute('src')
- links[0].get_attribute('href')
- #get Text of elements
- a=driver.find_elements_by_tag_name("a")
- for t in a:
- t.text
Add Comment
Please, Sign In to add comment