Completed
Push — master ( 32acac...19ae40 )
by Lakshmi
11:34
created

GetSearchResultsAction.run()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
import json
2
3
from google import google
4
5
from st2actions.runners.pythonrunner import Action
6
7
from lib.formatters import google_result_to_dict
8
9
__all__ = [
10
    'GetSearchResultsAction'
11
]
12
13
14
class GetSearchResultsAction(Action):
15
    def run(self, query, count=10):
16
        num_page = 1
17
18
        results = google.search(query, num_page)[:count]
19
        result = [google_result_to_dict(obj=obj) for obj in results]
20
        result = json.dumps(result)
21
        return result
22