堆栈交换API包装器

stackexchangep的Python项目详细描述


https://s7.postimg.cc/k6s2galrf/pylogo.pnghttps://img.shields.io/pypi/v/stackexchangepy.svg?style=flat-square:alt:PyPIhttps://img.shields.io/pypi/l/sctakexchangepy.svg?style=flat-square:alt:PyPI-License

stackexchange api包装器,用python3编写。

  • 安装

    Type pip3 install stackexchangepy in your cli.

  • 用法

    Usage can be seen in the documentation of the package.

  • 示例

    • 答案
    >>> from stackexchangepy.client import ExchangeClient
    >>> import datetime as dt
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> answers = client. \
    >>>             answers(). \
    >>>             fromdate(dt.datetime.today()). \
    >>>             order('desc'). \
    >>>             get()
    >>>
    >>> answers[0].answer_id
    123456
    >>> answers[0].owner.display_name
    User
    >>> answers[0].score
    1000
    >>> answers[0].is_accepted
    True
    >>>
    >>> questions = client. \
    >>>             answers(). \
    >>>             questions(). \
    >>>             get()
    >>>
    >>> questions[0].answers_count
    1
    >>> questions[0].is_answers
    False
    >>>
    
    • 徽章
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> badges = client. \
    >>>          badges(). \
    >>>          get()
    >>>
    >>> badges[0].award_count
    1
    >>> badges[0].user.display_name
    User
    >>> badges[0].rank
    gold
    >>>
    >>>
    >>> # By ID
    >>> badges = client. \
    >>>          badges(1, 2, 3). \
    >>>          get()
    
    • 评论
    >>> from stackexchangepy.client import ExchangeClient
    >>> import datetime as dt
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> comments = client. \
    >>>            comments(). \
    >>>            get()
    >>>
    >>> comments[0].comment_id
    12345678
    >>> comments[0].owner.display_name
    User
    >>> comments[0].score
    1
    >>>
    
    • 事件
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> events = client. \
    >>>          events(). \
    >>>          get()
    >>>
    >>> events[0].id
    1
    >>> events[0].event_type
    comment_posted
    >>>
    
    • 信息
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> info = client. \
    >>>        info(). \
    >>>        get()
    >>>
    >>> info.answers_per_minute
    100000
    >>> info.total_questions
    1
    >>> info.total_votes
    1
    >>>
    
    • 帖子
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> posts = client. \
    >>>         posts(). \
    >>>         get()
    >>>
    >>> posts[0].owner.display_name
    User
    >>> posts[0].score
    1
    >>>
    
    • 特权
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> privileges = client. \
    >>>              privileges(). \
    >>>              get()
    >>>
    >>> privileges[0].description
    Ask and answer questions
    >>> privileges[0].short_description
    create posts
    >>> privileges[0].reputation
    1
    >>>
    
    • 问题
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> questions = client. \
    >>>             questions(). \
    >>>             get()
    >>>
    >>> questions[0].answer_count
    1
    >>> questions[0].owner.display_name
    User
    >>> questions[0].question_id
    1
    >>>
    
    • 修订版
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> revisions = client. \
    >>>             revisions(1, 2, 3). \
    >>>             get()
    >>>
    >>> revisions[0].creation_date
    1526649575
    >>> revisions[0].last_body
    preceding body
    >>> revisions[0].last_title
    Old title
    >>>
    
    • 搜索
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> questions = client. \
    >>>            search(). \
    >>>            page(3). \
    >>>            pagesize(100). \
    >>>            intitle("Python"). \
    >>>            sort('creation'). \
    >>>            get()
    >>>
    >>> questions[0].owner.display_name
    User
    >>> questions[0].question_id
    1
    >>> # Advanced search
    >>> questions = client. \
    >>>             search(). \
    >>>             advanced(). \
    >>>             accepted(True). \
    >>>             closed(False). \
    >>>             wiki(True). \
    >>>             title("Python"). \
    >>>             get()
    >>>
    >>> # Similar questions
    >>> questions = client. \
    >>>             similar(). \
    >>>             title("Python"). \
    >>>             get()
    >>>
    >>> # Search excerpts
    >>>
    >>> questions = client. \
    >>>             search(). \
    >>>             excerpts(). \
    >>>             accepted(True). \
    >>>             closed(False). \
    >>>             get()
    >>>
    
    • 建议编辑
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> edits = client. \
    >>>         suggested_edits(). \
    >>>         get()
    >>>
    >>> edits[0].comment
    This is a comment
    >>> edits[0].title
    Python
    >>> edits[0].tags
    ["python", "python-3"]
    >>>
    
    • 标签
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> tags = client. \
    >>>        tags(). \
    >>>        get()
    >>>
    >>> tags[0].count
    1
    >>> tags[0].name
    python
    >>> tags[0].user_id
    1
    >>>
    
    • 用户
    >>> from stackexchangepy.client import ExchangeClient
    >>>
    >>>
    >>> client = ExchangeClient()
    >>>
    >>> users = client. \
    >>>         users(). \
    >>>         get()
    >>>
    >>> users[0].display_name
    User
    >>> users[0].user_id
    1
    >>> me = client. \
    >>>       me(). \
    >>>       get()
    >>>
    
    • 网络方法
    >>> from stackexchangepy.client import ExchangeClient
    >>> import os
    >>>
    >>> ACCESS_TOKEN = os.getenv('ACCESS_TOKEN')
    >>> KEY = os.getenv('KEY')
    >>>
    >>> client = ExchangeClient(access_token=ACCESS_TOKEN, key=KEY)
    >>>
    >>> tokens = client. \
    >>>          access_tokens("token1", "token2", "token3"). \
    >>>
    >>> tokens[0].access_token
    abcd*(01234
    >>> tokens[0].expires_on_date
    1526737772
    >>>
    >>> errors = client. \
    >>>          errors(). \
    >>>          get()
    >>>
    >>> errors[0].description
    Description
    >>> errors[0].error_id
    123456
    >>>
    >>> inbox = client. \
    >>>         inbox(). \
    >>>         get()
    >>>
    >>> inbox[0].answer_id
    12345
    >>> inbox[0].comment_id
    13567
    >>> inbox[0].title
    Some title
    >>>
    >>> notifications = client. \
    >>>                 notificaions(). \
    >>>                 get()
    >>>
    >>> notifications[0].body
    Body of the notification
    >>> notificatifications[0].is_unread
    True
    >>> notifications[0].creation_date
    1526737772
    >>>
    >>> sites = client. \
    >>>         sites(). \
    >>>         get()
    >>>
    >>> sites[0].launch_date
    1526651705
    >>> sites[0].twitter_account
    @StackExchange
    >>> sites[0].name
    Name of the site
    >>>
    
  • LICENSE

    GPL-3.0

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在用户输入的基础上使用applet绘制线条?在g为null的状态下发生的错误,如何修复   java频率源   java无法单击使用Selenium WebDriver创建的<div>下拉列表   java Wildfly 15在不同的机器上运行时不创建集群   Java:比较3个数字。得到他们中最伟大的   java与Maven/Hudson和TestNG一起使用多个类   java发生JNI错误(jdeveloper12c)   java在现实生活中同步多线程程序中的方法有什么意义   java Glassfish嵌入式JNDI模块范围查找   windows使用WMIC优雅地杀死Java进程   午夜(上午12点)java更新小部件失败   java无法解析方法“registerListener(com.xxx.xxx.MainActivity,安卓.hardware.SensorManager,int)”   java Hibernate版本属性在更改时调用自动更新?   java创建新线程是否会产生刷新缓存的副作用?   java saveAsTextFile性能改进   java如何自动化新的Facebook注册弹出窗口?   来自现有RDD的java Spark流媒体   AES256 OpenSSL C++和java加密:解密时的BADPADION异常