Store: Fix OReilly plugin.

This commit is contained in:
John Schember 2011-08-27 16:33:47 -04:00
parent e8be35ab44
commit 6c417f6e3c

View File

@ -45,20 +45,20 @@ class OReillyStore(BasicStoreConfig, StorePlugin):
counter = max_results counter = max_results
with closing(br.open(url, timeout=timeout)) as f: with closing(br.open(url, timeout=timeout)) as f:
doc = html.fromstring(f.read()) doc = html.fromstring(f.read())
for data in doc.xpath('//div[@id="results"]/div[@class="result"]'): for data in doc.xpath('//div[@class="result"]'):
if counter <= 0: if counter <= 0:
break break
full_id = ''.join(data.xpath('.//div[@class="title"]/a/@href')) full_id = ''.join(data.xpath('./div[@class="book_text"]//p[@class="title"]/a/@href'))
mo = re.search('\d+', full_id) mo = re.search('\d+', full_id)
if not mo: if not mo:
continue continue
id = mo.group() id = mo.group()
cover_url = ''.join(data.xpath('.//div[@class="bigCover"]//img/@src')) cover_url = ''.join(data.xpath('./a/img[1]/@src'))
title = ''.join(data.xpath('.//div[@class="title"]/a/text()')) title = ''.join(data.xpath('./div[@class="book_text"]/p[@class="title"]/a/text()'))
author = ''.join(data.xpath('.//div[@class="author"]/text()')) author = ''.join(data.xpath('./div[@class="book_text"]/p[@class="note"][1]/text()'))
author = author.split('By ')[-1].strip() author = author.split('By ')[-1].strip()
# Get the detail here because we need to get the ebook id for the detail_item. # Get the detail here because we need to get the ebook id for the detail_item.