Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-scraping-with-python
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Sameer Hussain
web-scraping-with-python
Commits
b7cfb787
Commit
b7cfb787
authored
Mar 16, 2022
by
Arham Noman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added error handling in pandas numeric conversion
parent
78d82c70
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
timer_function.py
timer_function.py
+2
-3
No files found.
timer_function.py
View file @
b7cfb787
...
@@ -7,7 +7,7 @@ from bs4 import BeautifulSoup as soup
...
@@ -7,7 +7,7 @@ from bs4 import BeautifulSoup as soup
from
urllib.request
import
urlopen
as
uReq
from
urllib.request
import
urlopen
as
uReq
import
pandas
as
pd
import
pandas
as
pd
my_url
=
"YOUR
_EBAY_LINK"
# Change this to your ebay
search url
my_url
=
"YOUR
EBAY URL"
# Change this to your
search url
def
main
(
mytimer
:
func
.
TimerRequest
)
->
None
:
def
main
(
mytimer
:
func
.
TimerRequest
)
->
None
:
utc_timestamp
=
datetime
.
datetime
.
utcnow
()
.
replace
(
utc_timestamp
=
datetime
.
datetime
.
utcnow
()
.
replace
(
...
@@ -21,7 +21,6 @@ def main(mytimer: func.TimerRequest) -> None:
...
@@ -21,7 +21,6 @@ def main(mytimer: func.TimerRequest) -> None:
page_soup
=
soup
(
page_html
,
'html.parser'
)
page_soup
=
soup
(
page_html
,
'html.parser'
)
divs
=
page_soup
.
findAll
(
'div'
,{
'class'
:
's-item__details clearfix'
})
divs
=
page_soup
.
findAll
(
'div'
,{
'class'
:
's-item__details clearfix'
})
# Extract relevant data from the soup object
# Extract relevant data from the soup object
prices
=
[]
prices
=
[]
...
@@ -34,7 +33,7 @@ def main(mytimer: func.TimerRequest) -> None:
...
@@ -34,7 +33,7 @@ def main(mytimer: func.TimerRequest) -> None:
# Clean data and save to a file for later use
# Clean data and save to a file for later use
prices
=
pd
.
DataFrame
(
pd
.
to_numeric
(
prices
)
)
prices
=
pd
.
DataFrame
(
pd
.
to_numeric
(
prices
,
errors
=
'coerce'
))
.
dropna
(
)
name
=
"PS5"
+
str
(
utc_timestamp
)
+
".csv"
name
=
"PS5"
+
str
(
utc_timestamp
)
+
".csv"
name
=
""
.
join
(
x
for
x
in
name
if
(
x
.
isalnum
()
or
x
in
"._- "
))
name
=
""
.
join
(
x
for
x
in
name
if
(
x
.
isalnum
()
or
x
in
"._- "
))
prices
.
to_csv
(
name
)
prices
.
to_csv
(
name
)
...
...
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