Created
July 17, 2013 21:34
-
-
Save alexkutsan/6024741 to your computer and use it in GitHub Desktop.
Python API. Wall get all, step 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import vk_auth | |
import vkontakte | |
import os | |
from optparse import OptionParser | |
parser = OptionParser() | |
parser.add_option("-e", "--email", dest="email", | |
help=" user email", metavar="EMAIL") | |
parser.add_option("-p", "--passwd", dest="passwd", | |
help="user password", metavar="PASSWD") | |
parser.add_option("-i", "--groupid", dest="gid", | |
help="group or public ID", metavar="GID") | |
parser.add_option("-c", "--count", dest="count", | |
help="count of posts to load", metavar="COUNT") | |
parser.add_option("-f", "--offset", dest="offset", | |
help="Begin loading from OFFSET post", metavar="OFFSET") | |
parser.add_option("-s", "--split", dest="split", | |
help="Spliting on SPLIT_NUM html blocks", metavar="SPLIT_NUM") | |
parser.add_option("-a", "--app_id", dest="app_id", | |
help="Application Id", metavar="APP_ID") | |
def main(): | |
(options, args) = parser.parse_args() | |
greeting = u'''Program will load %s posts from %s public, begining from %s post and split it on %s html blocks . | |
Auth data: | |
email: %s | |
passwd: %s | |
app id: %s '''%(options.count,options.gid,options.offset,options.split,options.email,options.passwd,options.app_id) | |
print greeting | |
(token,user_id) = vk_auth.auth(options.email, options.passwd, options.app_id, 'audio') | |
vk = vkontakte.API(token=token) | |
server_time = vk.getServerTime() | |
if(server_time): | |
res = vk.get('groups.getById', group_ids='39576543') | |
name = res[0]["name"] | |
print "Auth is success, for ",name | |
try: | |
os.mkdir(name) | |
except (OSError): | |
print "Directory Exist" | |
return 0 | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment