mirror of
https://github.com/searxng/searxng.git
synced 2024-11-23 19:31:00 +00:00
Merge pull request #1342 from bourrel/fix_wikidata_image
Update path to wikidata image
This commit is contained in:
commit
736f0fff0e
2 changed files with 14 additions and 10 deletions
|
@ -54,6 +54,7 @@ value_xpath = './/div[contains(@class,"wikibase-statementview-mainsnak")]'\
|
|||
+ '/*/div[contains(@class,"wikibase-snakview-value")]'
|
||||
language_fallback_xpath = '//sup[contains(@class,"wb-language-fallback-indicator")]'
|
||||
calendar_name_xpath = './/sup[contains(@class,"wb-calendar-name")]'
|
||||
media_xpath = value_xpath + '//div[contains(@class,"commons-media-caption")]//a'
|
||||
|
||||
|
||||
def request(query, params):
|
||||
|
@ -313,7 +314,7 @@ def add_image(result):
|
|||
for property_id in property_ids:
|
||||
image = result.xpath(property_xpath.replace('{propertyid}', property_id))
|
||||
if image:
|
||||
image_name = image[0].xpath(value_xpath)
|
||||
image_name = image[0].xpath(media_xpath)
|
||||
image_src = url_image.replace('{filename}', extract_text(image_name[0]))
|
||||
return image_src
|
||||
|
||||
|
|
|
@ -123,9 +123,10 @@ class TestWikidataEngine(SearxTestCase):
|
|||
<div class="wikibase-statementview-mainsnak">
|
||||
<div>
|
||||
<div class="wikibase-snakview-value">
|
||||
<a href="https://commons.wikimedia.org/wiki/File:image.png">
|
||||
image.png
|
||||
</a>
|
||||
<div class="commons-media-caption">
|
||||
<a href="https://commons.wikimedia.org/wiki/File:image.png">image.png</a>
|
||||
<br/>2,687 × 3,356; 1.22 MB
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -156,9 +157,10 @@ class TestWikidataEngine(SearxTestCase):
|
|||
<div class="wikibase-statementview-mainsnak">
|
||||
<div>
|
||||
<div class="wikibase-snakview-value">
|
||||
<a href="https://commons.wikimedia.org/wiki/File:icon.png">
|
||||
icon.png
|
||||
</a>
|
||||
<div class="commons-media-caption">
|
||||
<a href="https://commons.wikimedia.org/wiki/File:icon.png">icon.png</a>
|
||||
<br/>671 × 671; 18 KB</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -179,9 +181,10 @@ class TestWikidataEngine(SearxTestCase):
|
|||
<div class="wikibase-statementview-mainsnak">
|
||||
<div>
|
||||
<div class="wikibase-snakview-value">
|
||||
<a href="https://commons.wikimedia.org/wiki/File:logo.png">
|
||||
logo.png
|
||||
</a>
|
||||
<div class="commons-media-caption">
|
||||
<a href="https://commons.wikimedia.org/wiki/File:logo.png">logo.png</a>
|
||||
<br/>170 × 170; 1 KB
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue