Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
fdc0f701
Commit
fdc0f701
authored
Jun 10, 2013
by
Joshua Roesslein
Browse files
Merge pull request #296 from tweepy/search-v1.1
Change API.search() to use endpoint v1.1
parents
4d75a024
aedd73cf
Changes
3
Show whitespace changes
Inline
Side-by-side
tweepy/__init__.py
View file @
fdc0f701
...
@@ -9,7 +9,7 @@ __version__ = '2.0'
...
@@ -9,7 +9,7 @@ __version__ = '2.0'
__author__
=
'Joshua Roesslein'
__author__
=
'Joshua Roesslein'
__license__
=
'MIT'
__license__
=
'MIT'
from
tweepy.models
import
Status
,
User
,
DirectMessage
,
Friendship
,
SavedSearch
,
SearchResult
,
ModelFactory
,
Category
from
tweepy.models
import
Status
,
User
,
DirectMessage
,
Friendship
,
SavedSearch
,
SearchResult
s
,
ModelFactory
,
Category
from
tweepy.error
import
TweepError
from
tweepy.error
import
TweepError
from
tweepy.api
import
API
from
tweepy.api
import
API
from
tweepy.cache
import
Cache
,
MemoryCache
,
FileCache
from
tweepy.cache
import
Cache
,
MemoryCache
,
FileCache
...
...
tweepy/api.py
View file @
fdc0f701
...
@@ -628,12 +628,10 @@ class API(object):
...
@@ -628,12 +628,10 @@ class API(object):
""" search """
""" search """
search
=
bind_api
(
search
=
bind_api
(
search_api
=
True
,
path
=
'/search/tweets.json'
,
path
=
'/search.json'
,
payload_type
=
'search_results'
,
payload_type
=
'search_result'
,
payload_list
=
True
,
allowed_param
=
[
'q'
,
'lang'
,
'locale'
,
'since_id'
,
'geocode'
,
'show_user'
,
'max_id'
,
'since'
,
'until'
,
'result_type'
]
allowed_param
=
[
'q'
,
'lang'
,
'locale'
,
'rpp'
,
'page'
,
'since_id'
,
'geocode'
,
'show_user'
,
'max_id'
,
'since'
,
'until'
,
'result_type'
]
)
)
search
.
pagination_mode
=
'page'
""" trends/daily """
""" trends/daily """
trends_daily
=
bind_api
(
trends_daily
=
bind_api
(
...
...
tweepy/models.py
View file @
fdc0f701
...
@@ -229,33 +229,18 @@ class SavedSearch(Model):
...
@@ -229,33 +229,18 @@ class SavedSearch(Model):
return
self
.
_api
.
destroy_saved_search
(
self
.
id
)
return
self
.
_api
.
destroy_saved_search
(
self
.
id
)
class
SearchResult
(
Model
):
class
SearchResult
s
(
ResultSet
):
@
classmethod
@
classmethod
def
parse
(
cls
,
api
,
json
):
def
parse
(
cls
,
api
,
json
):
result
=
cls
()
metadata
=
json
[
'search_metadata'
]
for
k
,
v
in
json
.
items
():
results
=
SearchResults
(
metadata
.
get
(
'max_id'
),
metadata
.
get
(
'since_id'
))
if
k
==
'created_at'
:
results
.
refresh_url
=
metadata
.
get
(
'refresh_url'
)
setattr
(
result
,
k
,
parse_search_datetime
(
v
))
results
.
completed_in
=
metadata
.
get
(
'completed_in'
)
elif
k
==
'source'
:
results
.
query
=
metadata
.
get
(
'query'
)
setattr
(
result
,
k
,
parse_html_value
(
unescape_html
(
v
)))
else
:
for
status
in
json
[
'statuses'
]:
setattr
(
result
,
k
,
v
)
results
.
append
(
Status
.
parse
(
api
,
status
))
return
result
@
classmethod
def
parse_list
(
cls
,
api
,
json_list
,
result_set
=
None
):
results
=
ResultSet
(
json_list
.
get
(
'max_id'
,
json_list
.
get
(
'since_id'
)))
results
.
refresh_url
=
json_list
.
get
(
'refresh_url'
)
results
.
next_page
=
json_list
.
get
(
'next_page'
)
results
.
results_per_page
=
json_list
.
get
(
'results_per_page'
)
results
.
page
=
json_list
.
get
(
'page'
)
results
.
completed_in
=
json_list
.
get
(
'completed_in'
)
results
.
query
=
json_list
.
get
(
'query'
)
for
obj
in
json_list
[
'results'
]:
results
.
append
(
cls
.
parse
(
api
,
obj
))
return
results
return
results
...
@@ -433,7 +418,7 @@ class ModelFactory(object):
...
@@ -433,7 +418,7 @@ class ModelFactory(object):
direct_message
=
DirectMessage
direct_message
=
DirectMessage
friendship
=
Friendship
friendship
=
Friendship
saved_search
=
SavedSearch
saved_search
=
SavedSearch
search_result
=
SearchResult
search_result
s
=
SearchResult
s
category
=
Category
category
=
Category
list
=
List
list
=
List
relation
=
Relation
relation
=
Relation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment