diff options
| author | pw3t <romain@berthor.fr> | 2014-01-23 22:11:36 +0100 |
|---|---|---|
| committer | pw3t <romain@berthor.fr> | 2014-01-23 22:11:36 +0100 |
| commit | 132681b3aaf5b330d9d19624038b51fe2ebfd8d5 (patch) | |
| tree | 393114f41b487eea4b71dd4073903726310a1257 /searx/engines/twitter.py | |
| parent | d6b017efb5b51623a02c85690c7335cfc6674092 (diff) | |
| parent | 59eeeaab87951fd6fa3302ec240db98902a20b2c (diff) | |
Merge branch 'master' of https://github.com/asciimoo/searx
Diffstat (limited to 'searx/engines/twitter.py')
| -rw-r--r-- | searx/engines/twitter.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/searx/engines/twitter.py b/searx/engines/twitter.py index f9d9e26ad..23393ac4d 100644 --- a/searx/engines/twitter.py +++ b/searx/engines/twitter.py @@ -7,6 +7,9 @@ categories = ['social media'] base_url = 'https://twitter.com/' search_url = base_url+'search?' +title_xpath = './/span[@class="username js-action-profile-name"]//text()' +content_xpath = './/p[@class="js-tweet-text tweet-text"]//text()' + def request(query, params): global search_url @@ -21,7 +24,9 @@ def response(resp): for tweet in dom.xpath('//li[@data-item-type="tweet"]'): link = tweet.xpath('.//small[@class="time"]//a')[0] url = urljoin(base_url, link.attrib.get('href')) - title = ''.join(tweet.xpath('.//span[@class="username js-action-profile-name"]//text()')) - content = escape(''.join(tweet.xpath('.//p[@class="js-tweet-text tweet-text"]//text()'))) - results.append({'url': url, 'title': title, 'content': content}) + title = ''.join(tweet.xpath(title_xpath)) + content = escape(''.join(tweet.xpath(content_xpath))) + results.append({'url': url, + 'title': title, + 'content': content}) return results |