Created
July 12, 2020 09:21
-
-
Save Abhayparashar31/e7e2f84b4ba2ff1c11165af8e8d8d809 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} | |
def search(url): | |
res = requests.get(url,headers=headers) | |
print("\nSearching for history....\n") | |
print("Things happens today...\n") | |
soup = BeautifulSoup(res.text,'html.parser') | |
length = len(soup.select('.event')) | |
for i in range (0,length): | |
history = soup.select('.event')[i].getText().strip() | |
print(history) | |
url = 'https://www.onthisday.com/' | |
search(url) | |
while True: | |
user = input("\nWnat to search for a specific date\n").upper() | |
if user =='YES': | |
date = int(input("Enter the date")) | |
month = str(input("Enter the month name")) | |
url = f'https://www.onthisday.com/day/{month}/{date}' | |
search(url) | |
else: | |
print("\nok! Have a Nice Day") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment