Code Monkey home page Code Monkey logo

devrantsimple's Introduction

devRantSimple

A simple devRant api wrapper for the lazy people

Installation

First, get it from pip

pip install devRantSimple

Then, import the library

import devRantSimple as dRS

That's it!

Usage

These are the avalible functions and vars:

import devRantSimple as dRS

# Rant Types
# These are passed in to some functions to specify what data you want returned
dRS.RantType.algo   # Algo
dRS.RantType.top    # Top
dRS.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

# Functions
dRS.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}

More functions, data, and info will come soon.

Example

This is an example script that gets every rant posted by a user (one at a time) and prints it to the screen:

import devRantSimple ad dRS

username = "ewpratten

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

devrantsimple's People

Contributors

ewpratten avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.