-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathseleniumScraper.py
More file actions
60 lines (45 loc) · 1.63 KB
/
Copy pathseleniumScraper.py
File metadata and controls
60 lines (45 loc) · 1.63 KB
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
from selenium import webdriver
from selenium.webdriver.common.by import By
import time # allows delay
import os
email = os.getenv("EMAIL")
password = os.getenv("PASSWORD")
# sets up the chrome wbdriver
driver = webdriver.Chrome()
# opens the instant website
driver.get("https://mobile.instant.co/login")
time.sleep(2)
# array that holds all transaction strings
transactionTexts = []
#fills out email login
emailTextBar = driver.find_element(By.CSS_SELECTOR, "[data-testid='login-email']")
emailTextBar.click()
time.sleep(1)
emailTextBar.send_keys(email)
#fills out password login
passwordTextBar = driver.find_element(By.CSS_SELECTOR, "[data-testid='text-input-flat']")
passwordTextBar.click()
time.sleep(1)
passwordTextBar.send_keys(password)
time.sleep(1)
#clicks the login button
loginButton = driver.find_element(By.CSS_SELECTOR, "[data-testid='create-account-button-text']")
loginButton.click()
time.sleep(2)
#closes thing about using mobile app
closeButton = driver.find_element(By.CSS_SELECTOR, "[data-testid='button-text']")
closeButton.click()
time.sleep(1)
#clicks the 'More Transactions' button
moreTransacButton = driver.find_element(By.CSS_SELECTOR, "[data-testid='view-more-transactions-button-text']")
moreTransacButton.click()
time.sleep(5)
# collects and filters transaction texts that start with '+'
transactions = driver.find_elements(By.CSS_SELECTOR, "[data-testid='transactions-list-item-amount']")
for transaction in transactions:
if transaction.text and transaction.text[0] == '+':
transactionTexts.append(transaction.text)
# Print collected transaction texts
print(transactionTexts)
# closes the browser
driver.quit()