【翻译】Tweepy 3.5.0 Doc (1) Getting started

开始

简介

如果你是第一次接触Tweepy,就请从这里开始。这个教程的目标是提供你学习Tweepy所需的信息,让你学习完本教程后能熟练使用Tweepy。我们在这主要谈论重要的基础内容,而不会涉及太多细节,


你好 Tweepy

import tweepy

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

public_tweets = api.home_timeline()
for tweet in public_tweets:
    print tweet.text
这个例子可以下载你Twitter主页上的推文,并且把相应的文本内容打印到控制台。Twitter要求所有请求(requests)都通过OAuth协议进行授权(身份认证)。Authentication Tutorial(身份认证教程)(链接)中有授权的详细介绍。


API

API类为Twitter的所以REST API方法提供接口(The API class provides access to the entire twitter RESTful API methods.)每种方法接受不同的参数,但是都返回response。更多请参见API Reference(链接)


模型

当我们使用一种API方法时,我们大多数情况下会得到一个Tweepy model 类实例,其中包含了从Twitter返回的可以让我们应用到app中的数据。比如下面这行代码就返回了一个User model:

# Get the User object for twitter...
user = api.get_user('twitter')

Model中包含了数据和一些有用的方法:

print user.screen_name
print user.followers_count
for friend in user.friends():
   print friend.screen_name

更多内容请参见 ModelsReference(链接)



原文链接:

http://tweepy.readthedocs.io/en/v3.5.0/getting_started.html

微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码 微信小程序毕业设计期末大作业项目源码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值