Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from avinashkranjan:master #2

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
pull merged 18 commits into Uncodedtech:master from avinashkranjan:master
Apr 14, 2021
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1a9f064
Added Battery Notification Script
pankaj892 Mar 26, 2021
661616e
Update Battery-Notification/README.md
pankaj892 Mar 26, 2021
f84f18b
Update README.md
pankaj892 Mar 26, 2021
9ebc91b
Update SCRIPTS.md
pankaj892 Mar 27, 2021
e8a3559
Update SCRIPTS.md
pankaj892 Mar 28, 2021
54daeb9
Update Battery-Notification.py
pankaj892 Apr 6, 2021
e7367b1
GUI Implementation done
Ayushjain2205 Apr 9, 2021
c4bc0dd
web scraping and showing result in GUI complete
Ayushjain2205 Apr 9, 2021
a31fc40
requirements files added
Ayushjain2205 Apr 9, 2021
451308a
Readme file added
Ayushjain2205 Apr 9, 2021
6b16b1a
Update Battery-Notification.py
pankaj892 Apr 10, 2021
52a3abc
player data allignment fix
Ayushjain2205 Apr 10, 2021
b94ba81
2021 support added
Ayushjain2205 Apr 10, 2021
1152f09
readme updated with new UI screenshot
Ayushjain2205 Apr 10, 2021
0d86656
Update Battery-Notification/Battery-Notification.py
pankaj892 Apr 11, 2021
5873386
Update Battery-Notification.py
pankaj892 Apr 11, 2021
16b398f
Merge pull request #857 from Ayushjain2205/ipl-statistics-gui
avinashkranjan Apr 14, 2021
4a8bf7b
Merge pull request #746 from pankaj892/master
avinashkranjan Apr 14, 2021
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
Prev Previous commit
Next Next commit
web scraping and showing result in GUI complete
  • Loading branch information
Ayushjain2205 committed Apr 9, 2021
commit c4bc0dd1c39d083dc966f746eb3ac863feff495f
75 changes: 61 additions & 14 deletions IPL Statistics GUI/ipl.py
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@
# python program demonstrating
# Combobox widget using tkinter
import requests
from bs4 import BeautifulSoup
import tkinter as tk
from tkinter import ttk

# Dictionary containing category and corresponding slug value
categories = {'Most Runs': 'most-runs',
'Most Fours': 'most-fours', 'Most Sixes': 'most-sixes', 'Most Fifties': 'most-fifties',
'Most Centuries': 'most-centuries', 'Highest Scores': 'highest-scores', 'Most Wickets': 'most-wickets',
'Most Maidens': 'most-maidens', 'Most Dot Balls': 'most-dot-balls', 'Best Bowling Average': 'best-bowling-average',
'Best Bowling Economy': 'best-bowling-economy', 'Best Bowling Strike Rate': 'best-bowling-strike-rate'}

# Function to generate request url based on user choice
def generate_url():
category_choice = category.get()
year_choice = year.get()
if (year_choice == 'All time'):
year_choice = 'all-time'
category_slug = categories[category_choice]
url = 'https://www.iplt20.com/stats/{}/{}'.format(
year_choice, category_slug)
return url

# Function to scrape results based on request url
def scrape_results():
url = generate_url()
page = requests.get(url)

# Start scraping resultant html data
soup = BeautifulSoup(page.content, 'html.parser')
results = soup.find(
"table", {"class": "table table--scroll-on-tablet top-players"})
rows = results.findChildren('tr')

table_data = []
row_values = []
# Append player data into a list
for row in rows:
cells = row.findChildren(['th', 'td'])
for cell in cells:
value = cell.text.strip()
value = " ".join(value.split())
row_values.append(value)
table_data.append(row_values)
row_values = []

# Formatting the data stored in the list
p_records = ""
for player in table_data[:51]:
single_record = ""
for cell in player:
format_cell = "{:<40}"
single_record += format_cell.format(cell[:40])
single_record += "\n"
p_records += single_record

# Adding the formatted data into tkinter GUI
query_label['text'] = p_records


# Creating tkinter window
window = tk.Tk()
window.title('Combobox')
window.title('IPL Statistics')
window.geometry('800x850')

# label text for title
Expand All @@ -18,24 +73,19 @@
font=("Helvetica", 15)).grid(column=0,
row=5, padx=10, pady=25)


def getSearchvals():
print(category.get(), year.get())


# Combobox creation
category = ttk.Combobox(
window, width=27, state='readonly')
year = ttk.Combobox(
window, width=27, state='readonly')

submit_btn = ttk.Button(window, text="Search", command=getSearchvals)
submit_btn = ttk.Button(window, text="Search", command=scrape_results)

# Adding combobox drop down list
category['values'] = ('Most Runs', 'Most Fours',
'Most Sixes', 'Most Fifties', 'Most Centuries', 'Highest Scores', 'Most Wickets', 'Most Maidens', 'Most Dot Balls', 'Best Bowling Average', 'Best Bowling Economy', 'Best Bowling Strike Rate')

year['values'] = ('2020', '2019', '2018', '2017', '2016',
year['values'] = ('All time', '2020', '2019', '2018', '2017', '2016',
'2015', '2014', '2013', '2012', '2011', '2010', '2009', '2008')

category.grid(column=1, row=5, padx=10)
Expand All @@ -49,11 +99,8 @@ def getSearchvals():
frame = ttk.Frame(window)
frame.place(relx=0.50, rely=0.12, relwidth=0.98, relheight=0.90, anchor="n")

# global query_label
query_label = ttk.Label(
frame, anchor="nw", justify="left", text=("The workspace above has a list of tasks/ideas that could serve as utilities for managing OpenAPI specifications eg. cleanup tasks, adding default responses.\n")*50)
frame, anchor="nw", justify="left", text="")
query_label.grid(row=7, columnspan=2)

# query_label['text'] = "The workspace above has a list of tasks/ideas that could serve as utilities for managing OpenAPI specifications eg. cleanup tasks, adding default responses."

window.mainloop()

AltStyle によって変換されたページ (->オリジナル) /