ANTICHAT.XYZ    VIDEO.ANTICHAT.XYZ    НОВЫЕ СООБЩЕНИЯ    ФОРУМ  
Баннер 1   Баннер 2
Antichat снова доступен.
Форум Antichat (Античат) возвращается и снова открыт для пользователей. Здесь обсуждаются безопасность, программирование, технологии и многое другое. Сообщество снова собирается вместе.
Новый адрес: forum.antichat.xyz
Вернуться   Форум АНТИЧАТ > Программирование > PHP, PERL, MySQL, JavaScript
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

как запустить скрипт написанный на Python ?
  #1  
Старый 25.02.2010, 17:50
-tatarin-
Новичок
Регистрация: 09.02.2009
Сообщений: 5
Провел на форуме:
6720

Репутация: 0
Smile как запустить скрипт написанный на Python ?

Нашел в инете скрипт приглашения в друзья всех членов определенной группы вконтакте, но не знаю как запустить его, помогите пжл! Вот скрипт:
Код:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#  Created by Nuclear Worm
#
#
#  Vkontakte friends adder  #
#  Version 0.1.a.1
#

import os, sys, time, re, logging,  sqlite3,  urllib,  urllib2,  cookielib
try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO
VERSION='0.1.a.1'
COOKIEFILE = '/tmp/cookies1.lwp'
LOG_FILENAME = '/tmp/dbg.log'
logging.basicConfig(filename=LOG_FILENAME, filemode = 'w', level=logging.DEBUG,)

class PostCommand:
    def __init__(self, url, req = None):
        self.request  = req
        self.headers = ''
        self.url = url
    
    def perform(self):
        cj = cookielib.LWPCookieJar()
        if os.path.isfile(COOKIEFILE): cj.load(COOKIEFILE)
        url_retr = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        self.res =  url_retr.open(self.url,  self.request).read()
        cj.save(COOKIEFILE)
        logging.debug("Got to PostCommand request = %s, url = %s"%(self.request,  self.url))
        #self.res =  urllib.urlopen(self.url,  self.request).read()
        logging.debug("Got result = %s"%self.res)

class GetCommand:
    def __init__(self, url):
        self.headers = ''
        self.url = url
    def perform(self):
        cj = cookielib.LWPCookieJar()
        if os.path.isfile(COOKIEFILE): cj.load(COOKIEFILE)
        url_retr = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        self.res =  url_retr.open(self.url).read()
        cj.save(COOKIEFILE)
        logging.debug("Got to GetCommand url = %s"%(self.url))
        #self.res =  urllib.urlopen(self.url).read()
        logging.debug("Got result = %s"%self.res)
        
class Vkontakte:
    def __init__(self,  mail,  password):
        self.mail = mail
        self.password = password
        
    def login(self):
        request = 'op=a_login_attempt&email=' + self.mail + '&pass=' + self.password +'&expire=0'
        req = PostCommand('http://vkontakte.ru/login.php', request)
        req.perform()
        my_id = re.compile('good(\d+)')
        logging.debug("Reply from login:\n" + req.res)
        if "failed" in req.res: return "Error! Check your login/pass!"
        else:
            myid = my_id.search(req.res).groups()[0]
            return myid

class Group:
    def __init__(self, group_id):
        self.group_id = group_id
        
    def find(self,  datafile = None):
        if datafile: self.datafile = datafile
        else:
            print "No datafile to store your friends"
            sys.exit(1)
        gp = GetCommand('http://vkontakte.ru/search.php?group=' + self.group_id)
        gp.perform()
        logging.debug("Reply from login:\n" + gp.res)
        sum = re.compile('<strong>.* (\d+) .*\.</strong>')
        all_those = sum.search(gp.res).groups()[0]
        logging.debug("Sum of all users in group:\n" + all_those)
        friends = extract_id(gp.res)
        add_to_file(self.datafile, friends)
        time.sleep(1)
        for i in range(1, int(all_those)/10 + 1):
            gp = GetCommand('http://vkontakte.ru/search.php?&group=' + self.group_id + '&o=0&st=' + str(i*10))
            gp.perform()
            friends = extract_id(gp.res)
            add_to_file(self.datafile, friends)
            time.sleep(1)
        return sum


class Friend:
    def __init__(self):
        pass
    def add(self,  datafile = None,  limit = None,  message = None):
        if datafile: self.datafile = datafile
        else: pass
        if limit: self.limit = limit
        else: self.limit = 20000000
        if message: self.message = message
        else: self.message=''
        df = open(self.datafile, 'r')
        ind = 0
        hash_find = re.compile('id="hash" value="([^"]+)"')
        for line in df.readlines():
            id = line.strip(' \n')
            fp = PostCommand('http://vkontakte.ru/friends_ajax.php', req = 'act=request_form&fid=' + id)
            fp.perform()
            #print fp.res
            for line1 in fp.res.split('\\n'):
                if  hash_find.search(line1.replace('\\',  '')):
                    hash = hash_find.search(line1.replace('\\',  '')).groups()[0]
                    break
            try: hash
            except:
                print "Hash not found"
                logging.debug("Hash for user %s not found!"%id)
                continue
            fp = PostCommand('http://vkontakte.ru/friends_ajax.php',  req = 'act=accept_friend&fid=' + id + '&hash=' + hash +'&verbose=1&message=' + self.message)
            fp.perform()
            ind +=1
            if ind >= self.limit: break
        return ind
    

def extract_id(data):
    result = ''
    link = re.compile('<div class="info" id="row2(\d+)">')
    for line in StringIO(data).readlines():
        if link.search(line):
            result += link.search(line).groups()[0] + '\n'
    return result  


def write_file(file, string):
    file1 = open(file, 'w')
    file1.write(string)
    file1.close()

def add_to_file(file, data):
    file1 = open(file, 'a')
    file1.write(data)
    file1.close()

def main(*args):
    mail,  password = sys.argv[1:]
    #mail = "mymail@mail.ru"
    #password = "mypass"
    ###  For Windows change to your path
    tmp_file = '/tmp/group_mems'
    mail = mail.replace("@","%40")
    mylogin = Vkontakte(mail,  password).login()
    #print "Your ID = ", mylogin
    link = raw_input("Give link of group: ")
    group_id = re.search('http://vkontakte.ru/club(\d+)',  link).groups()[0]
    gr = Group(group_id)
    gr.find(datafile = tmp_file)
    
    fr = Friend()
    print "Added ", fr.add(datafile = tmp_file),  " friends"
    ###  Limit fo adding 30 friends, example:
    #print "Added ", fr.add(datafile = '/tmp/group_mems',  limit = 30),  " friends"
    ###  Add friends with message "Куку", example
    #message_to_send = urllib.quote("Куку")
    #print "Added ", fr.add(datafile = '/tmp/group_mems',  message = message_to_send),  " friends"

if __name__ == '__main__': main(sys.argv)
Или вот сылка http://code.google.com/p/socialbot/source/browse/trunk/trunk/kontakt.py
Прошу сильно не пинать, так в этом вопросе я еще большой новичок....
 
Ответить с цитированием

  #2  
Старый 25.02.2010, 17:58
shell_c0de
Reservists Of Antichat - Level 6
Регистрация: 07.07.2009
Сообщений: 324
Провел на форуме:
1585404

Репутация: 564
Отправить сообщение для shell_c0de с помощью ICQ Отправить сообщение для shell_c0de с помощью AIM
По умолчанию

Скачай интерпретатор питона и запускай =\
 
Ответить с цитированием

  #3  
Старый 25.02.2010, 18:37
-tatarin-
Новичок
Регистрация: 09.02.2009
Сообщений: 5
Провел на форуме:
6720

Репутация: 0
По умолчанию

Ну я это скачал уже был но потом он мне выдает ошибку вообщем вот сами смотрите:
Код:
ActivePython 2.6.4.10 (ActiveState Software Inc.) based on
Python 2.6.4 (r264:75706, Jan 22 2010, 16:41:54) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> #!/usr/bin/env python
... # -*- coding: utf-8 -*-
... #  Created by Nuclear Worm
... #
... #
... #  Vkontakte friends adder  #
... #  Version 0.1.a.1
... #
...
>>> import os, sys, time, re, logging,  sqlite3,  urllib,  urllib2,  cookielib
>>> try:
...     from cStringIO import StringIO
... except ImportError:
...     from StringIO import StringIO
... VERSION='0.1.a.1'
  File "<stdin>", line 5
    VERSION='0.1.a.1'
          ^
SyntaxError: invalid syntax
>>> COOKIEFILE = '/tmp/cookies1.lwp'
>>> LOG_FILENAME = '/tmp/dbg.log'
>>> logging.basicConfig(filename=LOG_FILENAME, filemode = 'w', level=logging.DEB
UG,)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\logging\__init__.py", line 1394, in basicConfig
    hdlr = FileHandler(filename, mode)
  File "C:\Python26\lib\logging\__init__.py", line 819, in __init__
    StreamHandler.__init__(self, self._open())
  File "C:\Python26\lib\logging\__init__.py", line 838, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 2] No such file or directory: 'C:\\tmp\\dbg.log'
>>>
>>> class PostCommand:
...     def __init__(self, url, req = None):
...         self.request  = req
...         self.headers = ''
...         self.url = url
...
...     def perform(self):
...         cj = cookielib.LWPCookieJar()
...         if os.path.isfile(COOKIEFILE): cj.load(COOKIEFILE)
...         url_retr = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
...         self.res =  url_retr.open(self.url,  self.request).read()
...         cj.save(COOKIEFILE)
...         logging.debug("Got to PostCommand request = %s, url = %s"%(self.requ
est,  self.url))
...         #self.res =  urllib.urlopen(self.url,  self.request).read()
...         logging.debug("Got result = %s"%self.res)
...
>>> class GetCommand:
...     def __init__(self, url):
...         self.headers = ''
...         self.url = url
...     def perform(self):
...         cj = cookielib.LWPCookieJar()
...         if os.path.isfile(COOKIEFILE): cj.load(COOKIEFILE)
...         url_retr = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
...         self.res =  url_retr.open(self.url).read()
...         cj.save(COOKIEFILE)
...         logging.debug("Got to GetCommand url = %s"%(self.url))
...         #self.res =  urllib.urlopen(self.url).read()
...         logging.debug("Got result = %s"%self.res)
...
... class Vkontakte:
  File "<stdin>", line 15
    class Vkontakte:
        ^
SyntaxError: invalid syntax
>>>     def __init__(self,  mail,  password):
  File "<stdin>", line 1
    def __init__(self,  mail,  password):
    ^
IndentationError: unexpected indent
>>>         self.mail = mail
  File "<stdin>", line 1
    self.mail = mail
    ^
IndentationError: unexpected indent
>>>         self.password = password
  File "<stdin>", line 1
    self.password = password
    ^
IndentationError: unexpected indent
>>>
...     def login(self):
  File "<stdin>", line 2
    def login(self):
    ^
IndentationError: unexpected indent
>>>         request = 'op=a_login_attempt&email=' + self.mail + '&pass=' + self.
password +'&expire=0'
  File "<stdin>", line 1
    request = 'op=a_login_attempt&email=' + self.mail + '&pass=' + self.password
 +'&expire=0'
    ^
IndentationError: unexpected indent
>>>         req = PostCommand('http://vkontakte.ru/login.php', request)
  File "<stdin>", line 1
    req = PostCommand('http://vkontakte.ru/login.php', request)
    ^
IndentationError: unexpected indent
>>>         req.perform()
  File "<stdin>", line 1
    req.perform()
    ^
IndentationError: unexpected indent
>>>         my_id = re.compile('good(\d+)')
  File "<stdin>", line 1
    my_id = re.compile('good(\d+)')
    ^
IndentationError: unexpected indent
>>>         logging.debug("Reply from login:\n" + req.res)
  File "<stdin>", line 1
    logging.debug("Reply from login:\n" + req.res)
    ^
IndentationError: unexpected indent
>>>         if "failed" in req.res: return "Error! Check your login/pass!"
  File "<stdin>", line 1
    if "failed" in req.res: return "Error! Check your login/pass!"
    ^
IndentationError: unexpected indent
>>>         else:
  File "<stdin>", line 1
    else:
    ^
IndentationError: unexpected indent
>>>             myid = my_id.search(req.res).groups()[0]
  File "<stdin>", line 1
    myid = my_id.search(req.res).groups()[0]
    ^
IndentationError: unexpected indent
>>>             return myid
  File "<stdin>", line 1
    return myid
    ^
IndentationError: unexpected indent
>>>
>>> class Group:
...     def __init__(self, group_id):
...         self.group_id = group_id
...
...     def find(self,  datafile = None):
...         if datafile: self.datafile = datafile
...         else:
...             print "No datafile to store your friends"
...             sys.exit(1)
...         gp = GetCommand('http://vkontakte.ru/search.php?group=' + self.group
_id)
...         gp.perform()
...         logging.debug("Reply from login:\n" + gp.res)
...         sum = re.compile('<strong>.* (\d+) .*\.</strong>')
...         all_those = sum.search(gp.res).groups()[0]
...         logging.debug("Sum of all users in group:\n" + all_those)
...         friends = extract_id(gp.res)
...         add_to_file(self.datafile, friends)
...         time.sleep(1)
...         for i in range(1, int(all_those)/10 + 1):
...             gp = GetCommand('http://vkontakte.ru/search.php?&group=' + self.
group_id + '&o=0&st=' + str(i*10))
...             gp.perform()
...             friends = extract_id(gp.res)
...             add_to_file(self.datafile, friends)
...             time.sleep(1)
...         return sum
...
>>>
>>> class Friend:
...     def __init__(self):
...         pass
...     def add(self,  datafile = None,  limit = None,  message = None):
...         if datafile: self.datafile = datafile
...         else: pass
...         if limit: self.limit = limit
...         else: self.limit = 20000000
...         if message: self.message = message
...         else: self.message=''
...         df = open(self.datafile, 'r')
...         ind = 0
...         hash_find = re.compile('id="hash" value="([^"]+)"')
...         for line in df.readlines():
...             id = line.strip(' \n')
...             fp = PostCommand('http://vkontakte.ru/friends_ajax.php', req = '
act=request_form&fid=' + id)
...             fp.perform()
...             #print fp.res
...             for line1 in fp.res.split('\\n'):
...                 if  hash_find.search(line1.replace('\\',  '')):
...                     hash = hash_find.search(line1.replace('\\',  '')).groups
()[0]
...                     break
...             try: hash
...             except:
...                 print "Hash not found"
...                 logging.debug("Hash for user %s not found!"%id)
...                 continue
...             fp = PostCommand('http://vkontakte.ru/friends_ajax.php',  req =
'act=accept_friend&fid=' + id + '&hash=' + hash +'&verbose=1&message=' + self.me
ssage)
...             fp.perform()
...             ind +=1
...             if ind >= self.limit: break
...         return ind
...
...
>>> def extract_id(data):
...     result = ''
...     link = re.compile('<div class="info" id="row2(\d+)">')
...     for line in StringIO(data).readlines():
...         if link.search(line):
...             result += link.search(line).groups()[0] + '\n'
...     return result
...
>>>
>>> def write_file(file, string):
...     file1 = open(file, 'w')
...     file1.write(string)
...     file1.close()
...
>>> def add_to_file(file, data):
...     file1 = open(file, 'a')
...     file1.write(data)
...     file1.close()
...
>>> def main(*args):
...     mail,  password = sys.argv[1:]
...     #mail = "mymail@mail.ru"
...     #password = "mypass"
...     ###  For Windows change to your path
...     tmp_file = '/tmp/group_mems'
...     mail = mail.replace("@","%40")
...     mylogin = Vkontakte(mail,  password).login()
...     #print "Your ID = ", mylogin
...     link = raw_input("Give link of group: ")
...     group_id = re.search('http://vkontakte.ru/club(\d+)',  link).groups()[0]

...     gr = Group(group_id)
...     gr.find(datafile = tmp_file)
...
...     fr = Friend()
...     print "Added ", fr.add(datafile = tmp_file),  " friends"
...     ###  Limit fo adding 30 friends, example:
...     #print "Added ", fr.add(datafile = '/tmp/group_mems',  limit = 30),  " f
riends"
...     ###  Add friends with message "Куку", example
...     #message_to_send = urllib.quote("Куку")
...     #print "Added ", fr.add(datafile = '/tmp/group_mems',  message = message
_to_send),  " friends"
...
>>> if __name__ == '__main__': main(sys.argv) ( нажал тут я enter)
...( появились эти 3 точки, я ще раз нажал enter и вот далее ошибка)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in main
ValueError: need more than 0 values to unpack
>>>
 
Ответить с цитированием

  #4  
Старый 26.02.2010, 02:31
undef
Новичок
Регистрация: 23.09.2009
Сообщений: 19
Провел на форуме:
21294

Репутация: 16
По умолчанию

Извращенец. Зачем копипастить файл интерпретатору? Установил свой ActiveState Python, cmd.exe -> DISK: -> cd \path\to\your\dir\ -> file.py
После установки его в систему, все .py файлы будут запускаться через него.
 
Ответить с цитированием

  #5  
Старый 26.02.2010, 16:52
Supermanoff
Banned
Регистрация: 02.01.2010
Сообщений: 5
Провел на форуме:
90887

Репутация: 0
По умолчанию

1. В предыдущем посте написано, что тебе надо сделать, чтобы запустить скрипт!
2. Скрипт этот уже давно не работает!
 
Ответить с цитированием

  #6  
Старый 26.02.2010, 20:11
-tatarin-
Новичок
Регистрация: 09.02.2009
Сообщений: 5
Провел на форуме:
6720

Репутация: 0
По умолчанию

Спсибо большое за помощь всем, действительно скрипт не рабочий((((((((.....Supermanoff, не знаешь существует ли новый скрипт? Буду очень рад если поможешь...........
 
Ответить с цитированием
Ответ



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Халявный Интернет (для маленьких) stopxaker Статьи 91 20.04.2010 19:52
Вредоносное ПО как феномен. Часть 1 Spider Agent Авторские статьи 9 21.03.2008 07:40
FAQ. Перед тем как задать вопрос. Fata1ex ICQ 1 04.11.2007 20:35
Как запустить PHP-файл на серваке если у него расширение не .php? bad_boy Форумы 13 13.11.2005 18:07
Что ломать? Almight Чаты 3 09.02.2004 18:48



Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT.XYZ