-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata.py
78 lines (67 loc) · 2.16 KB
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
import requests
from bs4 import BeautifulSoup
from datetime import date
import pandas as pd
import random
from dotenv import load_dotenv
load_dotenv()
FIXER_IO_API_KEY = os.getenv('FIXER_IO_API_KEY ')
def marathiNews():
#specify the url of marathi news website
url = "http://lokmat.com/"
soup = get_source_code(url)
news = soup.find('ul', class_='live-news-list')
for i in news.findAll('li'):
data = i.text
return data
def tarikh():
#specify the url of marathi date website
url = "http://lokmat.com/"
soup = get_source_code(url)
tdate = soup.find('p', class_='today-date')
return tdate.text
def suvichar():
num = random.randrange(1,365)
df = pd.read_csv("suvichar.csv", "r")
data = df.iloc[num,0]
return data
def graffiti():
num = random.randrange(1,365)
df = pd.read_csv("graffiti.csv", "r")
data = df.iloc[num,0]
return data
def dinVishesh():
d = date.today().strftime('%d-%B').lstrip("0").replace(" 0", " ").lower()
#specify the url of dinvishesh website
url = f"http://www.dinvishesh.com/{d}-janm/" #जन्म तारखे नुसार
soup = get_source_code(url)
vishesh_content = soup.find('div', class_='col-md-8 mt-5')
vishesh = vishesh_content.find_all('p')
for data in vishesh:
yield data.text
def bazar():
url = "http://marathi.webdunia.com/"
soup = get_source_code(url)
business = soup.find('div', class_='business')
for i in business.findAll('span'):
data = i.text
return data
def euro_to_inr():
res = requests.get(f'http://data.fixer.io/api/latest?access_key={FIXER_IO_API_KEY}&symbols=USD,INR&format=1')
result = res.json()
inr = result['rates']['INR']
usd = result['rates']['USD']
usd_to_inr = inr/usd
return usd_to_inr
def covid19():
res = requests.get('https://api.covid19india.org/data.json')
result = res.json()
data = result['statewise']
for stateinfo in data:
if stateinfo['state'] == 'Maharashtra':
return stateinfo
def get_source_code(url):
page = requests.get(url)
result = BeautifulSoup(page.text, 'html.parser')
return result