Skip to content
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

Web scrapping Bot #159

Merged
merged 3 commits into from
May 29, 2023
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
56 changes: 56 additions & 0 deletions Excel_Automation_Python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from openpyxl import Workbook, load_workbook
from openpyxl.utils import get_column_letter
from openpyxl.styles import Font

data = {
"James": {
"English": 65,
"Physics": 78,
"Computer": 98,
"History": 89
},
"Rhea": {
"English": 55,
"Physics": 77,
"Computer": 87,
"History": 95
},
"Harsh": {
"English": 100,
"Physics": 45,
"Computer": 75,
"History": 92
},
"Suman": {
"English": 30,
"Physics": 25,
"Computer": 45,
"History": 100
},
"Ryan": {
"English": 90,
"Physics": 100,
"Computer": 92,
"History": 60
}
}

wb = Workbook()
ws = wb.active
ws.title = "Student Marks"

headings = ['Name'] + list(data['James'].keys())
ws.append(headings)

for person in data:
marks = list(data[person].values())
ws.append([person] + marks)

for col in range(2, len(data['James']) + 2):
char = get_column_letter(col)
ws[char + "7"] = f"=SUM({char + '2'}:{char + '6'})/{len(data)}"

for col in range(1, 6):
ws[get_column_letter(col) + '1'].font = Font(bold=True, color="0099CCFF")

wb.save("StudentMarks.xlsx")
Binary file added Web Scrapper Bot/requirements.txt
Binary file not shown.
37 changes: 37 additions & 0 deletions Web Scrapper Bot/web_scrapping_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# importing the libraries and modules required
import requests
from bs4 import BeautifulSoup
from datetime import datetime
import time

while(True):
now = datetime.now()

# time of web-scrapping
current_time = now.strftime("%H:%M:%S")
print(f'At time : {current_time} IST')

response = requests.get('https://coinmarketcap.com/')
text = response.text
html_data = BeautifulSoup(text, 'html.parser')
headings = html_data.find_all('tr')[0]
headings_list = []
for x in headings:
headings_list.append(x.text)
headings_list = headings_list[:10]

data = []

for x in range(1, 6):
row = html_data.find_all('tr')[x]
column_value = row.find_all('td')
dict = {}

for i in range(10):
dict[headings_list[i]] = column_value[i].text
data.append(dict)

for values in data:
print(values)
print('')
time.sleep(600)