Browse Source

[fix] handle missing url in twitter results

Adam Tauber 9 years ago
parent
commit
28493d41a3
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      searx/engines/twitter.py

+ 6
- 2
searx/engines/twitter.py View File

55
 
55
 
56
     # parse results
56
     # parse results
57
     for tweet in dom.xpath(results_xpath):
57
     for tweet in dom.xpath(results_xpath):
58
-        link = tweet.xpath(link_xpath)[0]
58
+        try:
59
+            link = tweet.xpath(link_xpath)[0]
60
+            content = extract_text(tweet.xpath(content_xpath)[0])
61
+        except Exception:
62
+            continue
63
+
59
         url = urljoin(base_url, link.attrib.get('href'))
64
         url = urljoin(base_url, link.attrib.get('href'))
60
         title = extract_text(tweet.xpath(title_xpath))
65
         title = extract_text(tweet.xpath(title_xpath))
61
-        content = extract_text(tweet.xpath(content_xpath)[0])
62
 
66
 
63
         pubdate = tweet.xpath(timestamp_xpath)
67
         pubdate = tweet.xpath(timestamp_xpath)
64
         if len(pubdate) > 0:
68
         if len(pubdate) > 0: