Browse Source

Bing news engine corrections

XPath *never* return None.

(I found the HTML report of coverage)
Cqoicebordel 10 years ago
parent
commit
5761d6f0ab
1 changed files with 2 additions and 4 deletions
  1. 2
    4
      searx/engines/bing_news.py

+ 2
- 4
searx/engines/bing_news.py View File

59
         url = link.attrib.get('href')
59
         url = link.attrib.get('href')
60
         title = extract_text(link)
60
         title = extract_text(link)
61
         contentXPath = result.xpath('.//div[@class="sn_txt"]/div//span[@class="sn_snip"]')
61
         contentXPath = result.xpath('.//div[@class="sn_txt"]/div//span[@class="sn_snip"]')
62
-        if contentXPath is not None:
63
-            content = escape(extract_text(contentXPath))
62
+        content = escape(extract_text(contentXPath))
64
 
63
 
65
         # parse publishedDate
64
         # parse publishedDate
66
         publishedDateXPath = result.xpath('.//div[@class="sn_txt"]/div'
65
         publishedDateXPath = result.xpath('.//div[@class="sn_txt"]/div'
67
                                           '//span[contains(@class,"sn_ST")]'
66
                                           '//span[contains(@class,"sn_ST")]'
68
                                           '//span[contains(@class,"sn_tm")]')
67
                                           '//span[contains(@class,"sn_tm")]')
69
 
68
 
70
-        if publishedDateXPath is not None:
71
-            publishedDate = escape(extract_text(publishedDateXPath))
69
+        publishedDate = escape(extract_text(publishedDateXPath))
72
 
70
 
73
         if re.match("^[0-9]+ minute(s|) ago$", publishedDate):
71
         if re.match("^[0-9]+ minute(s|) ago$", publishedDate):
74
             timeNumbers = re.findall(r'\d+', publishedDate)
72
             timeNumbers = re.findall(r'\d+', publishedDate)