当前位置: 首页>>代码示例>>Python>>正文


Python Tweet.put方法代码示例

本文整理汇总了Python中models.Tweet.put方法的典型用法代码示例。如果您正苦于以下问题:Python Tweet.put方法的具体用法?Python Tweet.put怎么用?Python Tweet.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Tweet的用法示例。


在下文中一共展示了Tweet.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import put [as 别名]
	def get(self):
		self.response.write(self.request.get("keyword"))

		# Prompt for login credentials and setup stream object
		consumer_key = ""
		consumer_secret = ""
		access_token = ""
		access_token_secret = ""

		auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret)
		auth.set_access_token(access_token, access_token_secret)
		api = tweepy.API(auth)
		keyword = self.request.get("keyword")
		count =0
		search_results = api.search(q=keyword, result_type = "recent", count=100)
		for tweet in search_results: 
			if tweet.place != None:
				count+=1
				tweet.text.replace("\n", " ");				
				text = tweet.text.encode('utf8')
				print text
	            #logging.info(tweet.text)
				latitude = tweet.place.bounding_box.coordinates[0][0][0]
				longtitude = tweet.place.bounding_box.coordinates[0][0][1]
				
				e = Tweet(search_key=keyword, text=tweet.text, latitude= latitude, longtitude= longtitude)
				e.put()
开发者ID:ycc111,项目名称:TwittMap,代码行数:29,代码来源:twitter_api.py

示例2: get

# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import put [as 别名]
    def get(self):
        self.response.headers["Content-Type"] = "text/plain"

        myplace = self.request.get('place')

        urlbase = 'http://search.twitter.com/search.json'
        if myplace == 'Oxford':
            search_url = urlbase + '?geocode=51.751944%2C-1.257778%2C10km'
        elif myplace == 'London':
            search_url = urlbase + '?geocode=51.511676%2C-0.133209%2C10km'
        elif myplace == 'York':
            search_url = urlbase + '?geocode=53.958333%2C-1.080278%2C10km'
        elif myplace == 'Margate':
            search_url = urlbase + '?geocode=51.382681%2C1.3664245%2C10km'
        elif myplace == 'Bristol':
            search_url = urlbase + '?geocode=51.45%2C-2.583333%2C10km'
        else:
            self.response.out.write(("Please provide a 'place' parameter:"
                                     "Oxford, London, York, Bristol or Margate."))

        self.response.out.write('About to access: %s\n\n' % search_url)
        f = urlfetch.fetch(url=search_url)

        if f.status_code == 200:
            j = json.loads(f.content)
            for result in j['results']:
                self.response.out.write(result)
                self.response.out.write('\n')
                if (result['id']):
                    same_id = Tweet.gql('WHERE tweet_id = :1', result['id'])

                    if (same_id.count() > 0):
                        self.response.out.write('Tweet id #%s exists in the datastore\n'
                                                % result['id'])
                    else:
                        self.response.out.write('Adding tweet id #%s to datastore\n'
                                                % result['id'])
                        created_at = datetime.fromtimestamp(
                            mktime_tz(parsedate_tz(result['created_at'])))
                        tweet = Tweet(
                            tweet_id=result['id'],
                            tweet_content=result['text'],
                            place=myplace,
                            created_at=created_at
                        )

                        tweet.put()

        elif f.status_code == 400:
            self.response.out.write('UHOH! You have hit the rate limit...')
开发者ID:Justidan,项目名称:twitty-city,代码行数:52,代码来源:GrabTweetsHandler.py

示例3: store_tweet

# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import put [as 别名]
def store_tweet(data):
    logger.info("Adding tweet to datastore")
    logger.debug("Tweet data was:\n%s", pformat(data))
    tweet = Tweet(
        user_id=data['from_user_id'],
        username=data['from_user'],
        profile_image_url=data['profile_image_url'],
        message=data['text'],
        message_id=data['id'],
        created_at=datetime.strptime(data['created_at'], DATETIME_FORMAT),
    )
    if data['geo'] and data['geo']['type'] == 'Point':
        logger.debug("Adding location: %s", data['geo']['coordinates'])
        lat,lon = data['geo']['coordinates']
        tweet.location = "%s,%s" % (lat,lon)
    tweet.put()
开发者ID:gnublade,项目名称:ukbeermap,代码行数:18,代码来源:services.py

示例4: index

# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import put [as 别名]
def index(request):
	t = Tweet(tweet='test')
	t.put()
	return render_to_response('json_test/index.html', {'message': 'Hello'})
开发者ID:junpei0223,项目名称:ComFam,代码行数:6,代码来源:views.py

示例5: update_twitter_status

# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import put [as 别名]
def update_twitter_status(text, username, via):
	t = Tweet(text=text, user=username)
	if via == 'anon':
		t.via = False
	t.put()
	return
开发者ID:daveyshindig,项目名称:TweetMoar,代码行数:8,代码来源:tweetmoar.py


注:本文中的models.Tweet.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。