summaryrefslogtreecommitdiff
path: root/searx/engines/twitter.py
diff options
context:
space:
mode:
authorCqoicebordel <Cqoicebordel@users.noreply.github.com>2014-12-29 21:31:04 +0100
committerCqoicebordel <Cqoicebordel@users.noreply.github.com>2014-12-29 21:31:04 +0100
commit5d977056f7aa216eae09a22c3baaff73546f6ff1 (patch)
treeffd08f6bc1d3268ec6ce8031cbdec7987dfd3763 /searx/engines/twitter.py
parent576fdef440e835592f9f5c8dc25398e343687c7a (diff)
downloadsearxng-5d977056f7aa216eae09a22c3baaff73546f6ff1.tar.gz
searxng-5d977056f7aa216eae09a22c3baaff73546f6ff1.zip
Flake8 and Twitter corrections
Lots of Flake8 corrections Maybe we should change the rule to allow lines of 120 chars. It seems more usable. Big twitter correction : now it outputs the words in right order...
Diffstat (limited to 'searx/engines/twitter.py')
-rw-r--r--searx/engines/twitter.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/searx/engines/twitter.py b/searx/engines/twitter.py
index 5a7046c83..bd9a8c2fc 100644
--- a/searx/engines/twitter.py
+++ b/searx/engines/twitter.py
@@ -28,7 +28,7 @@ search_url = base_url+'search?'
results_xpath = '//li[@data-item-type="tweet"]'
link_xpath = './/small[@class="time"]//a'
title_xpath = './/span[@class="username js-action-profile-name"]//text()'
-content_xpath = './/p[@class="js-tweet-text tweet-text"]//text()'
+content_xpath = './/p[@class="js-tweet-text tweet-text"]'
timestamp_xpath = './/span[contains(@class,"_timestamp")]'
@@ -54,10 +54,11 @@ def response(resp):
link = tweet.xpath(link_xpath)[0]
url = urljoin(base_url, link.attrib.get('href'))
title = ''.join(tweet.xpath(title_xpath))
- content = escape(''.join(tweet.xpath(content_xpath)))
+ content = escape(html.tostring(tweet.xpath(content_xpath)[0], method='text', encoding='UTF-8').decode("utf-8"))
pubdate = tweet.xpath(timestamp_xpath)
if len(pubdate) > 0:
- publishedDate = datetime.fromtimestamp(float(pubdate[0].attrib.get('data-time')), None)
+ timestamp = float(pubdate[0].attrib.get('data-time'))
+ publishedDate = datetime.fromtimestamp(timestamp, None)
# append result
results.append({'url': url,
'title': title,