一个简单的面向懒人的devrant api包装器

devRantSimple的Python项目详细描述


开发简单

一个简单的面向懒人的devrant api包装器

安装

首先,从pip获取它

pip install devRantSimple

然后,导入库

importdevRantSimpleasdRS

就这样!

用法

这些是可用的函数和变量:

importdevRantSimpleasdRS# Rant Types# These are passed in to some functions to specify what data you want returneddRS.RantType.algo# AlgodRS.RantType.top# TopdRS.RantType.recent# Recent# Invalid Response# This is a string returned by some functions when something goes wrong.# It is always a smart idea to check if the thing returned by the function you are using is equal to this# If it is, you messsed up somewhere. (or the api changed)dRS.InvalidResponse# FunctionsdRS.getUserId("<username>")# Get a user id from a username (returns an int)dRS.userExists("<username>")# Check to see if a user exists with this username (returns a bool)dRS.getRant(dRS.RantType.<type>,<n>)# Get the n'th rant from list <type> # Example return data for these parameters: (dRS.RantType, 1):# {'id': 1604103, 'text:': "Oh yeah. Hey guys. 2 things. \nFirst off. Forgot to say. Officially got a job. Finally. So thank you for all the help/advice and patience with my depressive rants!! \n\nI'm in a new chapter of my life now so thanks. \n\nAnd secondly. \n\nI FUCKING HATE MY JOB", 'score': 66, 'username': 'al-m'}dRS.getUserRant("<username>",<n>)# Get the n'th most recent rant posted by <username># Example return data for these parameters: ("ewpratten", 1):# {'text': 'I wonder..\n\nDo the new devduck capes say "devrant.com" on the back? Or do they still say "devrant.io"', 'score': 20, 'tags': ['devrant', 'i wonder'], 'id': 1600704}

更多的功能、数据和信息将很快出现。

示例

这是一个示例脚本,它获取用户发布的每个rant(一次一个),并将其打印到屏幕:

importdevRantSimpleaddRSusername="ewprattenprevdata=""i=0whileprevdata!=dRS.InvalidResponse:prevdata=dRS.getUserRant(username,i)["text"]print(prevdata)i+=1

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

推荐PyPI第三方库


热门话题
java在JavaFX TableView中设置行高   java生成范围内的随机数   ProcessBuilder或DefaultExecutor启动的“RunAs”子进程的java读取标准输出   java ExoPlayer播放多个视频   基于匹配器的java Mockito ArgumentCaptor捕获条件   java正在创建更新程序。更新/下载部分   java请求。getAttribute()在servlet中不起作用   java Android Http请求:我不理解以下代码:   java ArrayList Failfast ConcurrentModificationException   if语句Java/LWJGL Pong AI问题   使用Oracle 10g长字段填充Grails域对象时的java空指针   当用户触摸屏时,java按钮不从左上角移动到右下角   未捕获javasocket读取IOException?   用Java绘制一段圆的几何图形?