8000 Capture the amount of money placed in bets by kmadisa · Pull Request #9 · kmadisa/mind-your-stonks · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Capture the amount of money placed in bets #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions scripts/bet_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.select import Select

(TICKET, EVENT_DATE, TOURNAMENT, EVENT, SELECTION, BET_TYPE,
STAKE, POTENTIAL_WIN, STATUS) = range(1, 10)

parser = argparse.ArgumentParser(description="Scrape the BET.co.za website"
" to obtain the account balance.")
Expand All @@ -16,7 +19,7 @@
help="Bet.co.za registered email address",)
parser.add_argument(
"--password",
required=True,
required=True,
help="Bet.co.za account password.",)

def main():
Expand All @@ -41,17 +44,42 @@ def main():
timestamp = driver.find_element_by_id("time").text.split("Your time: ")
timestamp = timestamp[-1].strip()
account_balance = driver.find_element_by_id("blocklogout_userBalanceText").text
driver.close()


print("Account Balance: R", account_balance)
print("Timestamp: ", timestamp)
date = datetime.date(datetime.now())
print("Date: ", date)


# Also need to get the amount of funds that is placed in bets
driver.find_element_by_link_text('My Betting History').click()
# Get the filter form
form_filter = driver.find_element_by_id('filter_form')
# Create a selector object for dropdown tables
selector = Select(form_filter.find_element_by_id('status'))
# Select 'Unsettled' bets
selector.select_by_visible_text('Unsettled')
# Click on the 'Go' button to filter bets
form_filter.find_element_by_class_name('inputBtn').click()
# Get the table object
table = driver.find_element_by_class_name('stdTable')
# Get all the rows on column number 7 (Stake)
col = table.find_elements_by_xpath("//tr/td["+str(STAKE)+"]")

# TODO Handle a situation with multiple pages.
money_in_bets = 0.00
for c in col:
money_in_bets += float(c.text)

print("Money in bets: R", money_in_bets)

driver.close()

with open('balance.csv', mode='w') as balance_file:
balance_writer = csv.writer(balance_file, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
balance_writer.writerow([date, account_balance, timestamp])
balance_writer.writerow([date, account_balance, timestamp, money_in_bets])

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion scripts/spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def main():
current_row_num = previous_row_num + 1
percentage_increase = "=ROUND(MINUS(B{},B{})/B{}, 2)".format(
current_row_num, previous_row_num, previous_row_num)
row.insert(-1, percentage_increase) # Move the timestamp to the last column
row.insert(2, percentage_increase) # Move the timestamp to the 2nd last column
# to preserve the structure of the table.
print(row)
sheet.append_row(row, value_input_option='USER_ENTERED')
Expand Down
0