这是错误:
maximum recursion depth exceeded while calling a Python object
我正在使用beautifulsoup解析从中接收到的网页 HTML,requests然后将解析后的数据存储到Product类中。该函数通过从 调用一个线程来运行ThreadPoolExecutor()。
运行功能:
executor = ThreadPoolExecutor()
t2 = executor.submit(ScrapePageFull, PageHtml)
product = t2.result()
ScrapePageFull功能:
def ScrapePageFull(data):
soup = BeautifulSoup(data)
product = Product()
# Price
price = soup.find(DIV, {ID: DATA_METRICS})[ASIN_PRICE]
product.price = float(price)
# ASIN
ASIN = soup.find(DIV, {ID: DATA_METRICS})[ASIN_ASIN]
product.asin = ASIN
# Title
title = soup.find(META, {NAME: TITLE})[CONTENT]
product.title = title
# Price String
price_string = soup.find(SPAN, {ID: PRICE_BLOCK}).text
product.price_string = price_string
return product
这是Product课程:
class Product:
def __init__(self):
self.title = None
self.price = None
self.price_string = None
self.asin = None
pass
# Getters
@property
def title(self):
return self.title
@property
def price(self):
return self.price
@property
def asin(self):
return self.asin
@property
def price_string(self):
return self.price_string
# Setters
@title.setter
def title(self, title):
self.title = title
@price.setter
def price(self, price):
self.price = price
@asin.setter
def asin(self, asin):
self.asin = asin
@price_string.setter
def price_string(self, price_string):
self.price_string = price_string
感谢您的帮助,谢谢。
慕田峪4524236
相关分类