コード例 #1
0
    def __init__(self, location, auth=None):

        if auth is None:
            self.client = RESTClient(location, None)
        else:
            self.client = RESTClient(location, auth)
        self.last_post = None
        self.location = location
コード例 #2
0
 def boost_post(self, votes):
     for i in tqdm(range(votes)):
         tmpClient = RESTClient(self.location, None)
         tmpClient.upvote(self.last_post)
         tmpClient.close()
コード例 #3
0
ファイル: votebot.py プロジェクト: Xanatiz/JodelPy
from jodelrest import RESTClient
from tqdm import *
import json

__author__ = 'Jan'

uni = {"latitude": 53.107, "longtitude": 8.853, "city": "Bremen"}

rc = RESTClient(uni, None)
posts = rc.get_posts()
rc.close()

for post in posts:
    if 'children' in post:
        print "[Comments : %s] [Votes : %s]" % (len(
            post['children']), post['vote_count'])
        #for comment in  post['children']:
        #    print "Kommentar : %s" % comment
    else:
        print "[Comments : 0] [Votes : %s]" % post['vote_count']

    print '%s' % (post['message'].encode('UTF-8'))
    var = str(raw_input("[ up / down / comment / view / exit ] : "))

    commands = {'up', 'down', 'comment', 'view', 'exit'}

    if var == 'exit':
        break

    id = post['post_id']
コード例 #4
0
ファイル: jodelpull.py プロジェクト: dottdottdott/JodelPy
                    help="read the Location from a file",
                    required=True)
parser.add_argument("-o",
                    "--outputfile",
                    help="the file the Jodel's should be written to")
args = parser.parse_args()

if args.from_file:
    if os.path.isfile(args.from_file):
        with open(args.from_file) as data_file:
            location = json.load(data_file)
    else:
        print 'File does not exist : %s' % args.from_file
        exit(0)

try:
    rc = RESTClient(location, None)

    if args.outputfile:
        filename = args.outputfile

        if not str(filename).endswith('.json'):
            filename = "%s%s" % (filename, '.json')

        with open(filename, 'w') as outfile:
            outfile.write(rc.get_posts_raw())
    else:
        print rc.get_posts_raw()
except ConnectionError:
    pass
コード例 #5
0
                    "--outputfile",
                    help="the file the Jodel's should be written to")
parser.add_argument("--tor",
                    action='store_true',
                    help="enable to add tor support")
args = parser.parse_args()

if args.from_file:
    if os.path.isfile(args.from_file):
        with open(args.from_file) as data_file:
            location = json.load(data_file)
    else:
        print 'File does not exist : %s' % args.from_file
        exit(0)

try:
    rc = RESTClient(location, None, args.tor)

    if args.outputfile:
        filename = args.outputfile

        if not str(filename).endswith('.json'):
            filename = "%s%s" % (filename, '.json')

        with open(filename, 'w') as outfile:
            outfile.write(rc.get_posts_raw())
    else:
        print rc.get_posts_raw()
except ConnectionError:
    pass