Skip to content

Commit cc3629d

Browse files
committed
Merge pull request #34 from gunvirranu/master
Implemented 'count' parameter in the search method. r=sudheesh
2 parents 04107b4 + abf09dc commit cc3629d

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ To update the user details within the server, package a `json` object with the f
120120

121121
Public search API for the scraped tweets from Twitter.
122122

123-
Query structure: `search('querycontent','since date','until date', 'from a specific user')`
123+
Query structure: `search('querycontent','since date','until date', 'from a specific user', '# of tweets')`
124124

125125
eg. l.search('doctor who')
126126

@@ -231,6 +231,10 @@ The `from a specific user` parameter makes sure that the results obtained for th
231231

232232
`l.search('doctor who', '2015-01-10', '2015-01-21','0rb1t3r')`
233233

234+
The `# of tweets` parameter is how many tweets will be returned.
235+
236+
`l.search('avengers', None, None, 'Iron_Man', 3)`
237+
234238
##### Aggregations API
235239

236240
##### GeoLocation API

loklak.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,26 @@ def settings(self):
126126
only localhost clients are granted.'
127127
return json.dumps(return_to_user)
128128

129-
def search(self, query=None, since=None, until=None, from_user=None):
129+
def search(self, query=None, since=None, until=None, from_user=None, count=None):
130130
"""Handles the searching"""
131131
search_application = 'api/search.json'
132132
url_to_give = self.baseUrl+search_application
133133
self.query = query
134134
self.since = since
135135
self.until = until
136136
self.from_user = from_user
137+
self.count = count
137138
if query:
138139
params = {}
139140
params['query'] = self.query
140141
if since:
141-
params['query'] = params['query']+' since:'+self.since
142+
params['query'] = params['query'] + ' since:'+self.since
142143
if until:
143-
params['query'] = params['query']+' until:'+self.until
144+
params['query'] = params['query'] + ' until:'+self.until
144145
if from_user:
145-
params['query'] = params['query']+' from:'+self.from_user
146+
params['query'] = params['query'] + ' from:'+self.from_user
147+
if count:
148+
params['count'] = self.count
146149
return_to_user = requests.get(url_to_give, params=params)
147150
if return_to_user.status_code == 200:
148151
return return_to_user.json()

sample.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
search6 = l.search('sudheesh001', '2015-01-10', '2015-01-21','sudheesh001')
104104
pprint(search6)
105105

106+
search7 = l.search('gunvirranu', None, None, None, 6)
107+
pprint(search7)
108+
106109
###loklak Suggestion API
107110
suggestion1 = l.suggest()
108111
pprint(suggest1)

0 commit comments

Comments
 (0)