mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get books: Update Google books plugin for markup changes
This commit is contained in:
parent
64141ab21f
commit
949ac56a5c
@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
store_version = 5 # Needed for dynamic plugin loading
|
store_version = 6 # Needed for dynamic plugin loading
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
@ -50,12 +50,16 @@ def search_google(query, max_results=10, timeout=60, write_html_to=None):
|
|||||||
for data in doc.xpath('//div[@id="rso"]//div[@class="g"]'):
|
for data in doc.xpath('//div[@id="rso"]//div[@class="g"]'):
|
||||||
if counter <= 0:
|
if counter <= 0:
|
||||||
break
|
break
|
||||||
|
h3 = data.xpath('descendant::h3')
|
||||||
id = ''.join(data.xpath('.//h3/a/@href'))
|
if not h3:
|
||||||
|
continue
|
||||||
|
h3 = h3[0]
|
||||||
|
a = h3.getparent()
|
||||||
|
id = a.get('href')
|
||||||
if not id:
|
if not id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
title = ''.join(data.xpath('.//h3/a//text()'))
|
title = ''.join(data.xpath('.//h3//text()'))
|
||||||
authors = data.xpath('descendant::div[@class="s"]//a[@class="fl" and @href]//text()')
|
authors = data.xpath('descendant::div[@class="s"]//a[@class="fl" and @href]//text()')
|
||||||
while authors and authors[-1].strip().lower() in ('preview', 'read', 'more editions'):
|
while authors and authors[-1].strip().lower() in ('preview', 'read', 'more editions'):
|
||||||
authors = authors[:-1]
|
authors = authors[:-1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user