python - AttributeError: 'dict' object has no attribute 'read' -
i new python. not able run following code throws attribute error. please help?
import tweepy import urllib import json api_key = "vdg3njsnkg49nbnb7gmhix" api_secret = "ybgkwe2k3qyk5ldny1eikiyeqawvlqkx1hbrctrfa9hk9" access_token_key = "110456973-h8caaet5cboea6fs4ckmk98xoadnjosxk45" access_token_secret = "wpulfaxs1tfrtlxs2vqjie5ffafclhjcwmmllpncb" auth = tweepy.auth.oauthhandler(api_key,api_secret) auth.set_access_token(access_token_key,access_token_secret) api=tweepy.api(auth,parser=tweepy.parsers.jsonparser()) results=api.search(q="microsoft",count=100) print type(results) print json.load(results)
results=api.search(q="microsoft",count=100) print type(results) print json.load(results)
results
here dict
.
there no need deserialize json.
see: tweepy.api.api.search()
reads:
api.search(q[, lang][, locale][, rpp][, page][, since_id][, geocode][, show_user])
returns tweets match specified query. parameters: q – search query string lang – restricts tweets given language, given iso 639-1 code. locale – specify language of query sending. intended language-specific clients , default should work in majority of cases. rpp – number of tweets return per page, max of 100. page – page number (starting @ 1) return, max of 1500 results (based on rpp * page. geocode – returns tweets users located within given radius of given latitude/longitude. location preferentially taking geotagging api, fall twitter profile. parameter value specified “latitide,longitude,radius”, radius units must specified either “mi” (miles) or “km” (kilometers). note cannot use near operator via api geocode arbitrary locations; can use geocode parameter search near geocodes directly. show_user – when true, prepends “<user>:” beginning of tweet. useful readers not display atom’s author field. default false. return type: list of searchresult objects
nb: "return type:"
Comments
Post a Comment