Commit b7cfb787 by Arham Noman

Added error handling in pandas numeric conversion

parent 78d82c70
......@@ -7,7 +7,7 @@ from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
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:
utc_timestamp = datetime.datetime.utcnow().replace(
......@@ -21,7 +21,6 @@ def main(mytimer: func.TimerRequest) -> None:
page_soup = soup(page_html, 'html.parser')
divs = page_soup.findAll('div',{'class':'s-item__details clearfix'})
# Extract relevant data from the soup object
prices = []
......@@ -34,7 +33,7 @@ def main(mytimer: func.TimerRequest) -> None:
# 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 = "".join( x for x in name if (x.isalnum() or x in "._- "))
prices.to_csv(name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment