areyoucodingson

Code

Sep 17th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. import driver as driver
  2. import pandas as pd
  3. import webdriver_manager.chrome
  4. from selenium.webdriver.chrome.service import Service
  5. from selenium.webdriver.common.by import By
  6. from selenium import webdriver
  7. import time
  8. from selenium.common.exceptions import TimeoutException
  9. options = webdriver.ChromeOptions()
  10. from selenium.webdriver.support import expected_conditions as EC
  11. #from selenium.webdriver.common.by import By
  12. from selenium import webdriver
  13. from selenium.webdriver.support.ui import WebDriverWait
  14. from selenium import webdriver
  15. from selenium.webdriver import ActionChains
  16. from selenium.webdriver.common.keys import Keys
  17. ###########################################################################################################################################################
  18.  
  19. options.add_argument('--start-maximized')
  20. options.add_experimental_option("detach", True)
  21. service = Service('driver/chromedriver.exe')
  22. driver = webdriver.Chrome(service=Service(webdriver_manager.chrome.ChromeDriverManager().install()), options=options)
  23. driver.get('https://www.betfair.com.au/exchange/plus/en/football-betting-1/15')
  24. WebDriverWait(driver, 100).until(lambda driver: driver.execute_script('return document.readyState') == 'complete')
  25. element = WebDriverWait(driver,20).until(lambda driver: driver.find_element(By.CSS_SELECTOR, ".name:nth-child(1) , bf-coupon-table:nth-child(1) tr:nth-child(1) .matched-amount-value"))
  26.  
  27. print('h')
  28. #time.sleep(5)
  29.  
  30. scroll = driver.find_element(By.CSS_SELECTOR, ".coupon-page-navigation__label--next")
  31. driver.execute_script("arguments[0].scrollIntoView();", scroll)
  32.  
  33. try:
  34. driver.find_element(By.CSS_SELECTOR, "#cookie-holder span").click()
  35. except:
  36. pass
  37.  
  38. from selenium.webdriver.common.by import By
  39. from selenium.webdriver.support.ui import WebDriverWait
  40. from selenium.webdriver.support import expected_conditions as EC
  41.  
  42. # < Less than—the number on the left is less than the number on the right; 2 < 3
  43. # > Greater than—the number on the left is greater than the number on the right; 3 > 2
  44. #driver.find_element(By.XPATH,'//a[contains(@href,"server_export")]').click()
  45. #css selector link click python selenium
  46. #https://stackoverflow.com/questions/33155454/how-to-find-an-element-by-href-value-using-selenium-python
  47. #bf-coupon-page-navigation > ul > li:nth-child(4) > a[href*=/exchange/plus/en/football
  48.  
  49.  
  50. i = 1
  51. while i < 6:
  52. try:
  53. time.sleep(2)
  54. #time.sleep(random, 3)
  55. WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".name:nth-child(1)")))
  56. WebDriverWait(driver, 100).until(lambda driver: driver.execute_script('return document.readyState') == 'complete')
  57. element = WebDriverWait(driver, 20).until(lambda driver: driver.find_element(By.CSS_SELECTOR, ".name:nth-child(1) , bf-coupon-table:nth-child(1) tr:nth-child(1) .matched-amount-value"))
  58. scroll = driver.find_element(By.CSS_SELECTOR, ".coupon-page-navigation__label--next")
  59. driver.execute_script("arguments[0].scrollIntoView();", scroll)
  60. link = driver.find_element_by_css_selector('[href^=http://somelink.com/]')
  61. WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "bf-coupon-page-navigation > ul > li:nth-child(4) > a")))
  62. NextStory = WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'bf-coupon-page-navigation > ul > li:nth-child(4) > a')))
  63. link = driver.find_element_by_css_selector('bf-coupon-page-navigation > ul > li:nth-child(4) > a')
  64. NextStory.click()
  65. except:
  66. i = 6
  67. print('ha gayyy')
  68. pass
Add Comment
Please, Sign In to add comment