-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhindiQuotes.py
More file actions
24 lines (19 loc) · 808 Bytes
/
Copy pathhindiQuotes.py
File metadata and controls
24 lines (19 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
from bs4 import BeautifulSoup
from datetime import date, timedelta
sdate = date(2009, 10, 1) # start date in format (year, month, day)
edate = date.today() # end date
delta = edate - sdate # as timedelta
lst = []
for i in range(delta.days + 1):
date = sdate + timedelta(days=i)
day = date.day
month = date.month
year = date.year
page = requests.get(f"https://www.shabdkosh.com/quote-of-the-day/english-hindi/{year}/{month}/{day}")
soup = BeautifulSoup(page.content, "html.parser")
tag = "blockquote"
arr = [text.get_text().replace("&dash", "–").replace("”", "” - ") for text in soup.find_all(tag)][:2]
if arr[0] in lst: continue
lst.append(arr[0])
print(date, arr[0], arr[1], sep="\n", end="\n\n")