Advertisement
thedenisnikulin

Untitled

Apr 10th, 2020
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. from selenium import webdriver
  2. from webdriver_manager.chrome import ChromeDriverManager
  3. import time
  4. from math import floor
  5. import numpy
  6. url = 'Ρ…ΡƒΠΉ'
  7.  
  8. driver = webdriver.Chrome(ChromeDriverManager().install())
  9. driver.get(url)
  10.  
  11. coef_xpath = '//*[@id="app"]/div[2]/div[1]/div[1]/div[1]/ul/li[1]/a/span'
  12. users_xpath = '//*[@id="app"]/div[2]/div[1]/div[2]/div[2]/ul/li[1]/b'
  13. cash_xpath = '//*[@id="app"]/div[2]/div[1]/div[2]/div[2]/ul/li[2]/b'
  14.  
  15. coef = None
  16. users = None
  17. cash = None
  18.  
  19. coef_arr = []
  20. users_arr = []
  21. cash_arr = []
  22.  
  23. iterations = 1000
  24.  
  25. for i in range(iterations):
  26.     coef = None
  27.     users = None
  28.     cash = None
  29.     while (users == None):
  30.         parsed_users = driver.find_element_by_xpath(users_xpath).text
  31.         print('inside, users: ' + parsed_users + ', iteration: ' + str(i))
  32.         if int(parsed_users) in [0, 1, 2]:
  33.                 print('it is 0')
  34.                 time.sleep(9)
  35.                 print('slept')
  36.                 users = driver.find_element_by_xpath(users_xpath).text
  37.                 cash = driver.find_element_by_xpath(cash_xpath).text
  38.                 coef = driver.find_element_by_xpath(coef_xpath).text
  39.                 print('old coef ' + coef)
  40.                 while (True):
  41.                     parsed_coef = driver.find_element_by_xpath(coef_xpath).text
  42.                     print('old ' + coef)
  43.                     print('new ' + parsed_coef)
  44.                     if (parsed_coef != coef):
  45.                         coef = parsed_coef
  46.                        
  47.                         coef_arr.append(round(float(coef.replace('x', '')), 2))
  48.                         users_arr.append(int(users))
  49.                         cash_arr.append(int(float(cash)))
  50.                         break
  51.  
  52. users_cash_arr = [list(a) for a in zip(users_arr, cash_arr)]
  53.  
  54.  
  55. print(coef_arr)
  56. print(users_cash_arr)
  57.  
  58. numpy.savetxt('coefs', coef_arr, delimiter=',')
  59. numpy.savetxt('users_cash', users_cash_arr, delimiter=',')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement