Skip to content

Commit

Permalink
Merge pull request #159 from RoopakMallik/web_scrapping_bot
Browse files Browse the repository at this point in the history
Web scrapping Bot
  • Loading branch information
shaishav06 committed May 29, 2023
2 parents c6c21ff + 01a12bb commit b72a7f3
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
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)

0 comments on commit b72a7f3

Please sign in to comment.