def __data_parser__(self, data):
html = etree.HTML(data)
search_results = []
for li in html.xpath('//li[@class="gl-item"]'):
try:
div = li.xpath('.//div[contains(@class, "p-img")]')[0]
search_results.append({
'url': div.xpath('./a/@href')[0],
'intro': div.xpath('./a/@title')[0],
'price': float(li.xpath('.//div[@class="p-price"]')[0]
.xpath('./strong/i/text()')[0].strip()),
'sales': li.xpath('.//div[@class="p-commit"]')[0]
.xpath('./strong/a/text()')[0].strip(),
'belong': colorful_text('??', Fore.CYAN)
})
except (IndexError, ValueError) as e:
error()
return search_results
评论列表
文章目录