-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
93 lines (56 loc) · 2.04 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import time
from getpass import getpass
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import ElementNotInteractableException
from selenium.webdriver.firefox.options import Options as FirefoxOptions
#import selenium.webdriver.common.expected_conditions as ExpectedConditions
from bs4 import BeautifulSoup
options = webdriver.FirefoxOptions()
options.headless = True
url = 'https://app.plus500.com'
driver = webdriver.Firefox(options=options)
#driver = webdriver.Firefox()
#driver.get(url)
driver.get(url + '/closed-positions')
driver.implicitly_wait(5)
driver.maximize_window()
log = driver.find_element_by_id("realMoney")
log.click()
#ExpectedConditions.element_to_be_clickable(driver.find_element_by_id("newUserCancel")
try:
account = driver.find_element_by_id("newUserCancelExperiment")
ActionChains(driver).move_to_element(account)
driver.implicitly_wait(2)
account.click()
except ElementNotInteractableException as exception:
account = driver.find_element_by_id("newUserCancel")
ActionChains(driver).move_to_element(account)
driver.implicitly_wait(2)
account.click()
email = driver.find_element_by_id("email")
mail = input("Mail: ")
email.send_keys(mail)
passwd = driver.find_element_by_id("password")
pswd = getpass()
passwd.send_keys(pswd)
login = driver.find_element_by_id("submitLogin")
login.click()
#driver.get(url + '/closed-positions')
time.sleep(10)
#driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
title = driver.find_element_by_id("closedPositionsScrollWrapper")
title.send_keys(Keys.END)
time.sleep(2)
source = driver.page_source
soup = BeautifulSoup(source, 'html.parser')
#out = open("pl.html", "w")
#out.write(source)
#out.close()
#values = driver.find_element_by_id("closedPositionsScrollWrapper")
#poss = driver.find_elements_by_class_name("net-pl")
poss = soup.find_all(class_ = "net-pl")
for pos in poss:
print(pos.text)
driver.close()