diff options
| author | dalf <alex@al-f.net> | 2014-12-07 16:37:56 +0100 |
|---|---|---|
| committer | dalf <alex@al-f.net> | 2014-12-07 16:37:56 +0100 |
| commit | 7c13d630e4531630ce3c392a7d60752715742291 (patch) | |
| tree | 332019feae5a215d2d54528308792560794d7aa5 /searx/engines/bing_images.py | |
| parent | ffcec383b7355c6ca8b60da8579a43019d7d7e6b (diff) | |
[fix] pep8 : engines (errors E121, E127, E128 and E501 still exist)
Diffstat (limited to 'searx/engines/bing_images.py')
| -rw-r--r-- | searx/engines/bing_images.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/searx/engines/bing_images.py b/searx/engines/bing_images.py index b3eabba45..6c5e49bc9 100644 --- a/searx/engines/bing_images.py +++ b/searx/engines/bing_images.py @@ -1,17 +1,19 @@ ## Bing (Images) -# +# # @website https://www.bing.com/images -# @provide-api yes (http://datamarket.azure.com/dataset/bing/search), max. 5000 query/month -# +# @provide-api yes (http://datamarket.azure.com/dataset/bing/search), +# max. 5000 query/month +# # @using-api no (because of query limit) # @results HTML (using search portal) # @stable no (HTML can change) # @parse url, title, img_src # -# @todo currently there are up to 35 images receive per page, because bing does not parse count=10. limited response to 10 images +# @todo currently there are up to 35 images receive per page, +# because bing does not parse count=10. +# limited response to 10 images from urllib import urlencode -from cgi import escape from lxml import html from yaml import load import re @@ -51,15 +53,15 @@ def response(resp): dom = html.fromstring(resp.content) # init regex for yaml-parsing - p = re.compile( '({|,)([a-z]+):(")') + p = re.compile('({|,)([a-z]+):(")') # parse results for result in dom.xpath('//div[@class="dg_u"]'): link = result.xpath('./a')[0] # parse yaml-data (it is required to add a space, to make it parsable) - yaml_data = load(p.sub( r'\1\2: \3', link.attrib.get('m'))) - + yaml_data = load(p.sub(r'\1\2: \3', link.attrib.get('m'))) + title = link.attrib.get('t1') #url = 'http://' + link.attrib.get('t3') url = yaml_data.get('surl') @@ -69,7 +71,7 @@ def response(resp): results.append({'template': 'images.html', 'url': url, 'title': title, - 'content': '', + 'content': '', 'img_src': img_src}) # TODO stop parsing if 10 images are found |