Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- from pickle import dump
- COOKIES_FILE = 'lib/cookies.pkl'
- from selenium.webdriver.chrome.options import Options
- from selenium.webdriver.common.keys import Keys
- from seleniumwire import webdriver
- def get_chrome():
- print("START get_chrome")
- chrome_options = Options()
- chrome_options.add_argument('--headless')
- chrome_options.add_argument('--no-sandbox')
- chrome_options.add_argument('--disable-dev-shm-usage')
- options = {
- 'proxy': {
- 'http': 'http://login:[email protected]:8000',
- 'https': 'https://login:[email protected]:8000',
- 'no_proxy': 'localhost,127.0.0.1' # excludes
- }
- }
- d = webdriver.Chrome(executable_path='/usr/bin/chromedriver', seleniumwire_options=options, options=chrome_options)
- return d
- def save_cookie( cookies):
- dump(cookies, open(COOKIES_FILE, "wb"))
- print("OK save cookies")
- def auth():
- print("START auth")
- d = get_chrome()
- d.get('https://spv.kadastr.ru/api/v1/login')
- sleep(3)
- # print(d.page_source)
- try:
- login_field = d.find_element_by_css_selector('input#login')
- except:
- send_message("SPV скрипт умер, не нашел login поле в госуслугах")
- pass_field = d.find_element_by_css_selector('input#password')
- # button id="loginByPwdButton" type="button" class="ui-button ui-widget button-big
- submit = d.find_element_by_css_selector('.button-big')
- login_field.send_keys(LOGIN)
- pass_field.send_keys(PASS)
- sleep(1)
- submit.click()
- sleep(3)
- d.get('https://spv.kadastr.ru/')
- sleep(1)
- print("OK auth")
- save_cookie(d.get_cookies())
- d.quit()
- auth()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement