Skip to content

Commit e247ae8

Browse files
committed
change dashboard to checker
1 parent 716acd4 commit e247ae8

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

Crypto-price-checker/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Cryptocurreny Price Checker GUI
2+
3+
Running this Script would allow the user to fetch live top-100 cryptocurrency prices scraped from [cointracker.io](https://www.cointracker.io).
4+
5+
## Setup instructions
6+
7+
In order to run this script, you need to have Python and pip installed on your system. After you're done installing Python and pip, run the following command from your terminal to install the requirements from the same folder (directory) of the project.
8+
9+
```
10+
pip install -r requirements.txt
11+
```
12+
13+
As this script uses selenium, you will need to install the chrome webdriver from [this link](https://sites.google.com/a/chromium.org/chromedriver/downloads)
14+
15+
After satisfying all the requirements for the project, Open the terminal in the project folder and run
16+
17+
```
18+
python crypto.py
19+
```
20+
21+
or
22+
23+
```
24+
python3 crypto.py
25+
```
26+
27+
depending upon the python version. Make sure that you are running the command from the same virtual environment in which the required modules are installed.
28+
29+
## Output
30+
31+
The top-100 cryptocurrencies are displayed along with some data about their performance
32+
33+
![Screenshot of the GUI](https://i.postimg.cc/25TbtvJL/crypto.png)
34+
35+
36+
## Author
37+
38+
[Ayush Jain](https://github.com/Ayushjain2205)

Crypto-price-checker/crypto.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
import tkinter as tk
4+
from tkinter import ttk
5+
from tkinter import font as tkFont
6+
from selenium import webdriver
7+
from selenium.webdriver.common.keys import Keys
8+
import time
9+
10+
driver_path = input('Enter chrome driver path')
11+
12+
13+
# Function to scrape stock data from generated URL
14+
def scraper():
15+
url = 'https://www.cointracker.io/price'
16+
driver = webdriver.Chrome(driver_path)
17+
driver.get(url)
18+
19+
# Wait for results to load
20+
time.sleep(5)
21+
html = driver.page_source
22+
23+
# Start scraping resultant html data
24+
soup = BeautifulSoup(html, 'html.parser')
25+
26+
# Find the crypto price table to scrape
27+
results = soup.find("table", {"class": 'table mx-auto'})
28+
rows = results.findChildren('tr')
29+
30+
table_data = []
31+
row_values = []
32+
# Append individual cryptocurrency data into a list
33+
for row in rows:
34+
cells = row.findChildren(['th', 'td'])
35+
for cell in cells:
36+
value = cell.text.strip()
37+
value = " ".join(value.split())
38+
row_values.append(value)
39+
table_data.append(row_values)
40+
row_values = []
41+
42+
# Formatting the cryptocurrency data stored in the list
43+
stocks_data = ""
44+
for stock in table_data:
45+
single_record = ""
46+
for cell in stock:
47+
format_cell = "{:<30}"
48+
single_record += format_cell.format(cell[:20])
49+
single_record += "\n"
50+
stocks_data += single_record
51+
52+
# Adding the formatted data into tkinter GUI
53+
query_label.config(state=tk.NORMAL)
54+
query_label.delete(1.0,"end")
55+
query_label.insert(1.0,stocks_data)
56+
query_label.config(state=tk.DISABLED)
57+
driver.close()
58+
59+
# Creating tkinter window
60+
window = tk.Tk()
61+
window.title('Cryptocurrency Price Checker')
62+
window.geometry('1200x1000')
63+
window.configure(bg='white')
64+
65+
style = ttk.Style()
66+
style.configure('my.TButton', font=('Helvetica', 16))
67+
style.configure('my.TFrame', background='white')
68+
69+
# label text for title
70+
ttk.Label(window, text="Cryptocurrency Price Checker",
71+
background='white', foreground="DodgerBlue2",
72+
font=("Helvetica", 30, 'bold')).grid(row=0, column=3,padx=300)
73+
74+
submit_btn = ttk.Button(window, text="Fetch Live Price!", style='my.TButton', command = scraper)
75+
submit_btn.grid(row=5, column=3, pady=5, padx=15, ipadx=5)
76+
77+
frame = ttk.Frame(window, style='my.TFrame')
78+
frame.place(relx=0.50, rely=0.12, relwidth=0.98, relheight=0.90, anchor="n")
79+
80+
# To display stock data
81+
query_label = tk.Text(frame ,height="52" ,width="500", bg="lightskyblue1")
82+
query_label.grid(row=7, columnspan=2)
83+
84+
window.mainloop()

Crypto-price-checker/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
requests
2+
beautifulsoup4
3+
selenium

0 commit comments

Comments
 (0)