-
Notifications
You must be signed in to change notification settings - Fork 0
/
deezer_interface.py
51 lines (34 loc) · 1.15 KB
/
deezer_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from time import sleep
from fake_useragent import UserAgent
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
field_ids = {
'gdpr': 'gdpr-btn-accept-all',
'username': 'login_mail',
'password': 'login_password',
'button': 'login_form_submit'
}
def get_arl(deezer):
options = Options()
ua = UserAgent()
user_agent = ua.random
options.add_argument(f'user-agent={user_agent}')
options.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=options, executable_path='/usr/local/bin/chromedriver')
driver.get(deezer['login_url'])
print(driver.page_source)
sleep(10)
driver.find_element(value=field_ids['gdpr']).click()
sleep(3)
driver.find_element(value=field_ids['username']).send_keys(deezer['username'])
driver.find_element(value=field_ids['password']).send_keys(deezer['password'])
sleep(3)
driver.find_element(value=field_ids['button']).click()
sleep(10)
cookies = driver.get_cookies()
for x in cookies:
if x['name'] == 'arl':
driver.quit()
return x['value']
driver.quit()
return cookies