Spaces:
Sleeping
Sleeping
Neurolingua
commited on
Commit
•
bebbf0f
1
Parent(s):
e6d5541
Update other_function.py
Browse files- other_function.py +12 -1
other_function.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
import requests
|
3 |
from requests.auth import HTTPBasicAuth
|
4 |
from PIL import Image
|
@@ -90,4 +91,14 @@ def convert_img(url, account_sid, auth_token):
|
|
90 |
except requests.exceptions.HTTPError as err:
|
91 |
print(f"HTTP error occurred: {err}")
|
92 |
except Exception as err:
|
93 |
-
print(f"An error occurred: {err}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
from bs4 import BeautifulSoup
|
3 |
import requests
|
4 |
from requests.auth import HTTPBasicAuth
|
5 |
from PIL import Image
|
|
|
91 |
except requests.exceptions.HTTPError as err:
|
92 |
print(f"HTTP error occurred: {err}")
|
93 |
except Exception as err:
|
94 |
+
print(f"An error occurred: {err}")
|
95 |
+
def get_weather(city):
|
96 |
+
city=city.strip()
|
97 |
+
city=city.replace(' ',"+")
|
98 |
+
r = requests.get(f'https://www.google.com/search?q=weather+in+{city}')
|
99 |
+
|
100 |
+
soup=BeautifulSoup(r.text,'html.parser')
|
101 |
+
temperature=soup.find('div',attrs={'class':'BNeawe iBp4i AP7Wnd'}).text
|
102 |
+
degree=temperature[:-2]
|
103 |
+
celcius=str(round((int(degree) - 32)* 5/9,1))+temperature[-2]+'C'
|
104 |
+
return (celcius)
|