瀏覽代碼

[enh] add result number parsing to google engine

Adam Tauber 8 年之前
父節點
當前提交
52d1087202
共有 1 個檔案被更改,包括 6 行新增0 行删除
  1. 6
    0
      searx/engines/google.py

+ 6
- 0
searx/engines/google.py 查看文件

221
     instant_answer = dom.xpath('//div[@id="_vBb"]//text()')
221
     instant_answer = dom.xpath('//div[@id="_vBb"]//text()')
222
     if instant_answer:
222
     if instant_answer:
223
         results.append({'answer': u' '.join(instant_answer)})
223
         results.append({'answer': u' '.join(instant_answer)})
224
+    try:
225
+        results_num = int(dom.xpath('//div[@id="resultStats"]//text()')[0]
226
+                          .split()[1].replace(',', ''))
227
+        results.append({'number_of_results': results_num})
228
+    except:
229
+        pass
224
 
230
 
225
     # parse results
231
     # parse results
226
     for result in dom.xpath(results_xpath):
232
     for result in dom.xpath(results_xpath):