Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-020
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
O.V.B Sewmina
2022-020
Commits
ce96f4bb
Commit
ce96f4bb
authored
Oct 07, 2022
by
W.P.S.M wickramage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
fcf17a50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
testingWeather.py
testingWeather.py
+19
-0
No files found.
testingWeather.py
0 → 100644
View file @
ce96f4bb
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
weather
(
city
):
city
=
city
.
replace
(
" "
,
"+"
)
res
=
requests
.
get
(
f
'https://www.google.com/search?q={city}&oq={city}&aqs=chrome.0.35i39l2j0l4j46j69i60.6128j1j7&sourceid=chrome&ie=UTF-8'
,
headers
=
headers
)
soup
=
BeautifulSoup
(
res
.
text
,
'html.parser'
)
location
=
soup
.
select
(
'#wob_loc'
)[
0
]
.
getText
()
.
strip
()
time
=
soup
.
select
(
'#wob_dts'
)[
0
]
.
getText
()
.
strip
()
info
=
soup
.
select
(
'#wob_dc'
)[
0
]
.
getText
()
.
strip
()
weather
=
soup
.
select
(
'#wob_tm'
)[
0
]
.
getText
()
.
strip
()
return
weather
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment