forked from ankurgajurel/rashifal-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_data.py
62 lines (44 loc) · 1.34 KB
/
all_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
from bs4 import BeautifulSoup
import requests
base = "https://hamropatro.com/rashifal"
def get_rashifal(work_url):
""" unites function to get scrape a specific element
Args:
work_url (str): this is the url to the API
Returns:
str: unicode of the rashifal nepali
"""
response = requests.get(work_url)
soup = BeautifulSoup(response.text, 'html.parser')
return_rashifal = soup.find('div', {'class': 'desc'}).find('p').text
return return_rashifal
def get_daily(rashi):
"""daily rashifal
Args:
rashi (str): which rashi
Returns:
dict: rashifal message
"""
work_url = base + "/daily/" + rashi
daily_rashifal = get_rashifal(work_url)
return {"daily_rashifal" + "_" + rashi: daily_rashifal}
def get_monthly(rashi):
"""monthly rashifal
Args:
rashi (str): which rashi
Returns:
dict: rashifal message
"""
work_url = base + "/monthly/" + rashi
monthly_rashifal = get_rashifal(work_url)
return {"daily_rashifal" + "_" + rashi: monthly_rashifal}
def get_yearly(rashi):
"""yearly rashifal
Args:
rashi (str): which rashi
Returns:
dict: rashifal message
"""
work_url = base + "/yearly/" + rashi
yearly_rashifal = get_rashifal(work_url)
return {"daily_rashifal" + "_" + rashi: yearly_rashifal}