def solve(self, session, captcha_url): captcha_id = 0 captcha_result = '' captcha_url = re.sub('[\\\]', '', captcha_url) requester = HRequester() requester(captcha_url, session) response = requester.request() for r in response: with tempfile.NamedTemporaryFile(suffix='.jpg') as temp: temp.write(r[0].content) temp.flush() # Отправляем на рукапча изображение капчи captcha_id = self.postCaptcha(session, temp.name) break while True: captcha_result = self.getResult(session, captcha_id) if captcha_result == 'CAPCHA_NOT_READY': print('captcha_class', captcha_result) pass elif captcha_result == 'error': print('captcha_class', captcha_result) return 'error' else: print('captcha_class', captcha_result) return captcha_result
def getResult(self, session, captcha_id): requester = HRequester() dataGet = { 'key': self.token, 'action': 'get', 'id': captcha_id, 'json': '1' } time.sleep(5) requester(self.urlGet, session, params=dataGet) requester( self.urlGet, session, ) response = requester.request() for r in response: j = json.loads(r[0].text) if j['request'] == 'CAPCHA_NOT_READY': return 'CAPCHA_NOT_READY' elif j['status'] == 1: return j['request'] elif j['request'] == 'ERROR_ZERO_BALANCE': print('Нет денег на балансе') return 'error' else: print(j) return 'error'
def addFriends(self): requester = HRequester() for item in self.chil: getUrl = UrlAPI(item.token) requester(getUrl.friends.getRequests(count=1000, out=0), item.session, item) response = requester.request() for r in response: try: j = json.loads(r[0].text)['response'] item = r[2][0] masReceived = [received for received in j['items']] self.listRecived.append([item, masReceived]) except Exception as e: print(e) widgetList = [w for w in self.listRecived if len(w[1]) > 0] for w in widgetList: item, masReceived = w getUrl = UrlAPI(item.token) added_user_id = self.getAddedUser(masReceived) if added_user_id != None: requester(getUrl.friends.add(user_id=added_user_id), item.session) requester.request()
def chekAcc(self): errorListAcc = [] requester = HRequester() chil = [ item for item in self.itemList if item.b.checkState() == 2 and item.frozen == 0 ] for acc in chil: getUrl = UrlAPI(acc.token) requester(getUrl.account.setOnline(), acc.session, acc) requests = requester.request() for r in requests: acc = r[2][0] j = json.loads(r[0].text) if 'response' in j: if j['response'] == 1: pass else: print(j) return elif 'error' in j: acc.responseError = j errorListAcc.append(acc) if len(errorListAcc) == 0: self.statusBar.showMessage('Обновленно') else: self.widgetsConductor(SurveyForm(self, errorListAcc), show=True)
def sendRequest(self): getUrl = UrlAPI(self.item.token) requester = HRequester() for i in range(3): user = random.choice(self.parent.members['items']) requester(getUrl.friends.add(user_id=user['id']), self.item.session) response = requester.request() for r in response: j = json.loads(r[0].text) if 'error' in j: if j['error']['error_code'] == 14: print('КАПЧА-----') else: print(j) elif 'response' in j: if j['response'] == 1: print('Запрос отправлен') self.countSendedRequests.setText(str(int(self.countSendedRequests.text()) + 1)) else: print(j) else: print(j)
def lineRepostDownload(self): self.group_list_repost = [] post_str = self.gui.lineRepost.text().strip('https://vk.com/wall') requester = HRequester() acc = random.choice(self.chil) getUrl = UrlAPI(acc.token) url = getUrl.wall.getById(posts=post_str, extended=1) requester(url, acc.session) response = requester.request() for r in response: try: j = json.loads(r[0].text) except: continue if 'response' in j: for group in j['response']['groups']: self.group_list_repost.append(group['id']) self.signal.emit() else: print(j)
def filing(self): requester = HRequester() for acc in self.chil: getUrl = UrlAPI(acc.token) urlAvatars = getUrl.users.get(fields='photo_200') requester(urlAvatars, acc.session, acc) response = requester.request() for r in response: acc = r[2][0] try: dataAvatars = json.loads(r[0].text)['response'][0] if dataAvatars[ 'photo_200'] != 'https://vk.com/images/camera_200.png': requester(dataAvatars['photo_200'], acc.session, acc) else: photo = Photo(self, None, acc) self.mainLayout.addWidget(photo, alignment=Qt.AlignLeft) except Exception as e: print(repr(e)) response = requester.request() for r in response: acc = r[2][0] photoByte = r[0] photo = Photo(self, photoByte, acc) self.mainLayout.addWidget(photo, alignment=Qt.AlignLeft)
def __init__(self, parent=None, mas=None): super().__init__(parent, Qt.Window) self.ui() self.masSessions = mas self.requester = HRequester() self.btn_send.clicked.connect(self.leaveGroup) self.show()
def resevedOneFriend(self): requester = HRequester() countCaptcha = 0 countLimitRequests = 0 countSuccessfully = 0 widgetList = [w for w in self.widgetList if len(w.masReceived) > 0] for w in widgetList: getUrl = UrlAPI(w.item.token) added_user_id = w.masReceived.pop(0) requester(getUrl.friends.add(user_id=added_user_id), w.item.session, w, added_user_id) response = requester.request() for r in response: w = r[2][0] added_user_id = r[2][1] j = json.loads(r[0].text) if 'error' in j: if j['error']['error_code'] == 14: countCaptcha += 1 elif j['error']['error_code'] == 6: countLimitRequests += 1 elif j['error']['error_code'] == 177: getUrl = UrlAPI(w.item.token) rDel = w.item.session.get(getUrl.friends.delete(user_id=added_user_id), proxies=w.item.session.proxies) countSuccessfully += 1 else: print(j) elif 'response' in j: if j['response'] > 1: countSuccessfully += 1 w.countReceivedRequests.setText(str(int(w.countReceivedRequests.text()) - 1)) else: print(j) else: print(j) if countSuccessfully / len(response) == 1: self.parent.statusBar.showMessage('Успешно добавлено у всех') print('Успешно добавлено у всех') else: self.parent.statusBar.showMessage('Кол-во успешных:' + str(countSuccessfully) + ' Кол-во капч:' + str( countCaptcha) + ' Кол-во лимитов:' + str(countLimitRequests)) print('Кол-во успешных:' + str(countSuccessfully) + ' Кол-во капч:' + str( countCaptcha) + ' Кол-во лимитов:' + str(countLimitRequests))
def __init__(self, name, token, session): self.name = name self.timeout = 0 self.interval1 = 75 self.interval2 = 95 self.session = session self.getUrl = UrlAPI(token) self.requester = HRequester() self.photoIdsList = []
def refreshName(self): errorListAcc = [] requester = HRequester() chil = [(item.session, item.token, item.user_id) for item in self.itemList if item.b.checkState() == 2 and item.frozen == 0] error = 0 for acc in chil: session = acc[0] token = acc[1] user_id = acc[2] getUrl = UrlAPI(token) requester(getUrl.account.getProfileInfo(), session, user_id) with self.con: cur = self.con.cursor() cur.execute("SELECT name, last_name, user_id FROM accaunt") rows = cur.fetchall() requests = requester.request() for r in requests: user_id1 = r[2][0] j = json.loads(r[0].text) if 'response' in j: name = j['response']['first_name'] lastName = j['response']['last_name'] nameG, lastNameG, user_idG = [ m for m in rows if user_id1 == m[2] ].pop() if name == nameG and lastName == lastNameG: pass else: with self.con: cur = self.con.cursor() cur.execute( "UPDATE accaunt SET name=?, last_name=? WHERE user_id=?", (name, lastName, user_id1)) self.con.commit() elif 'error' in j: error += 1 acc.responseError = j errorListAcc.append(acc) if error == 0: self.statusBar.showMessage('Обновленно') else: self.statusBar.showMessage('Обновленно. Проблемных аккаунтов:' + str(error)) self.widgetsConductor(SurveyForm(self, errorListAcc), show=True)
def __init__(self, parent=None): super().__init__(parent, Qt.Window) self.reposts = [] self.requester = HRequester() self.ui() self.getRepostsFromBD() self.downloadReposts() QShortcut(QtGui.QKeySequence(Qt.Key_Escape), self).activated.connect(self.close)
def unsubscribeEverything(self): requester = HRequester() countCaptcha = 0 countLimitRequests = 0 countSuccessfully = 0 for w in self.widgetList: getUrl = UrlAPI(w.item.token) for i in range(5): try: user = w.masSended.pop(0) requester(getUrl.friends.delete(user_id=user), w.item.session, w) except: break response = requester.request() for r in response: w = r[2][0] j = json.loads(r[0].text) if 'error' in j: if j['error']['error_code'] == 14: countCaptcha += 1 elif j['error']['error_code'] == 6: countLimitRequests += 1 else: print(j) elif 'response' in j: if j['response']['success'] == 1: countSuccessfully += 1 w.countSendedRequests.setText(str(int(w.countSendedRequests.text()) - 1)) else: print(j) else: print(j) if countSuccessfully / len(response) == 1: self.parent.statusBar.showMessage('Успешно удалено у всех') print('Успешно удалено у всех') else: self.parent.statusBar.showMessage('Кол-во успешных:' + str(countSuccessfully) + ' Кол-во капч:' + str( countCaptcha) + ' Кол-во лимитов:' + str(countLimitRequests)) print('Кол-во успешных:' + str(countSuccessfully) + ' Кол-во капч:' + str( countCaptcha) + ' Кол-во лимитов:' + str(countLimitRequests))
def save(self): requester = HRequester() dic = {} if self.lineName.text() == '': pass else: dic.update(first_name=self.lineName.text()) if self.lineLastName.text() == '': pass else: dic.update(last_name=self.lineLastName.text()) if self.lineBD.text() == '': pass else: dic.update(bdate=self.lineBD.text()) if self.lineCityId.text() == '': pass else: dic.update(city_id=self.lineCityId.text()) if self.lineStatus.text() == '': pass else: dic.update(status=self.lineStatus.text()) if self.lineVisibleBD.checkState() == 2: dic.update(bdate_visibility=1) else: dic.update(bdate_visibility=0) for acc in self.chil: getUrl = UrlAPI(acc.token) # Close coments under wall post and display walls record url1 = getUrl.account.setInfo(name='own_posts_default', value=0) url2 = getUrl.account.setInfo(name='no_wall_replies', value=1) requester(url1, acc.session) requester(url2, acc.session) requester(getUrl.account.saveProfileInfo(**dic), acc.session) response = requester.request() for r in response: j = json.loads(r[0].text) print(j)
def setPhotos(self, acc, dataPhotos): requester = HRequester() for item in dataPhotos['items']: urlPhoto = item['photo_604'] requester(urlPhoto, acc.session, item['id']) response = requester.request() for r in response: photoByte = r[0] photoId = r[2][0] photo = Photo(self, photoByte, photoId, acc) self.mainLayout.addWidget(photo, alignment=Qt.AlignLeft)
def mouseDoubleClickEvent(self, QMouseEvent): requester = HRequester() getUrl = UrlAPI(self.acc.token) requester(getUrl.photos.delete(photo_id=self.id), self.acc.session) response = requester.request() for r in response: j = json.loads(r[0].text) try: if j['response'] == 1: self.deleteLater() except Exception as e: print(repr(e))
def mouseDoubleClickEvent(self, QMouseEvent): requester = HRequester() getUrl = UrlAPI(self.acc.token) requester(getUrl.photos.deleteAlbum(album_id=self.albumId), self.acc.session) response = requester.request() for r in response: j = json.loads(r[0].text) try: if j['response'] == 1: self.deleteLater() except KeyError: print(KeyError, 'Ошибка удаления альбома', r[0])
def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui() self.widgetList = [] self.nuberOfCall = 0 self.parent = parent requester = HRequester() postRequester = HPostRequester() self.closeBtn.clicked.connect(lambda: self.parent.widgetsConductor(self, delete=True)) self.btn_unsubscribeEverything.clicked.connect(self.unsubscribeEverything) self.btn_resevedOneFriend.clicked.connect(self.resevedOneFriend) chil = [item for item in self.parent.itemList if item.b.checkState() == 2 and item.frozen == 0] for item in chil: getUrl = UrlAPI(item.token) postRequester(getUrl.execute(), item.session, item, data={'code': self.getCode()}) response = postRequester.request() response.sort(key=lambda r: json.loads(r[0].text)['response'][0]['count']) for r in response: j = json.loads(r[0].text)['response'] item = r[2][0] masSended = [sended for sended in j[1]['items']] masReceived = [received for received in j[2]['items']] self.addAccaunt(item, str(j[0]['count']), str(j[1]['count']), str(j[2]['count']), masSended, masReceived) self.parent.statusBar.showMessage( 'Загруженно акков ' + str(len(response)) + '/' + str(len(chil)))
def settingPrivacy(self): requester = HRequester() con = sql.connect('db/db.sqlite3') cur = con.cursor() #Login responseLoginPage = self.session.get('https://m.vk.com', proxies=self.session.proxies) soup = BeautifulSoup(responseLoginPage.text) urlLogin = soup.find('form').get('action') with con: cur.execute( 'SELECT login, pass, user_id FROM accaunt WHERE token = ?', (self.token, )) row = cur.fetchone() login = row[0] password = row[1] user_id = row[2] self.session.params.update(email=login) self.session.params.update({'pass': password}) responseLogin = self.session.get(urlLogin, allow_redirects=False, proxies=self.session.proxies) params = ['mail_send', 'profile', 'audios', 'gifts', 'wall_send'] for param in params: self.setting(param) # Close coments under wall post and display walls record url1 = self.createApi.account.setInfo(name='own_posts_default', value=0) url2 = self.createApi.account.setInfo(name='no_wall_replies', value=1) requester(url1, self.session) requester(url2, self.session) response = requester.request() for r in response: j = json.loads(r[0].text) if j['response'] == 1: print( 'Успешно включено отображение записей на стене пользователя и закрыты коментарии на стене' )
def deleteAll(self): requester = HRequester() for post in self.gui.allPost: getUrl = UrlAPI(post.token) requester(getUrl.wall.delete(post_id=post.post_id), post.session, post) response = requester.request() for r in response: j = json.loads(r[0].text) post = r[2][0] if j['response'] == 1: post.deleteLater() else: print('Error Response by delete post', r[0].text)
def sendRequestEverything(self): requester = HRequester() countCaptcha = 0 countSuccessfully = 0 for w in self.widgetList: getUrl = UrlAPI(w.item.token) for i in range(3): user = random.choice(self.members['items']) requester(getUrl.friends.add(user_id=user['id']), w.item.session, w) response = requester.request() for r in response: w = r[2][0] j = json.loads(r[0].text) if 'error' in j: if j['error']['error_code'] == 14: countCaptcha += 1 else: print(j) elif 'response' in j: if j['response'] == 1: countSuccessfully += 1 w.countSendedRequests.setText(str(int(w.countSendedRequests.text()) + 1)) elif j['response'] == 2: print('Добавлен ранее') else: print(j) else: print(j) if countSuccessfully / len(self.widgetList) == 3: self.parent.statusBar.showMessage('Успешно отправлено у всех') print('Успешно отправлено у всех') else: self.parent.statusBar.showMessage( 'Кол-во успешных:' + str(countSuccessfully) + ' Кол-во капч:' + str(countCaptcha)) print('Кол-во успешных:' + str(countSuccessfully) + ' Кол-во капч:' + str(countCaptcha))
def __init__(self, parent=None): QWidget.__init__(self, parent) self.con = sql.connect('db/db.sqlite3') self.cur = self.con.cursor() self.ui() self.parent = parent self.btn_avatar.clicked.connect(self.avatar) self.btn_numRecord.clicked.connect(self.numRecord) self.btn_specificRecord.clicked.connect(self.specificRecord) self.chil = [ item for item in self.parent.itemList if item.b.checkState() == 2 and item.frozen == 0 ] self.lenght = len(self.chil) self.requester = HRequester()
def filing(self, acc): requester = HRequester() getUrl = UrlAPI(acc.token) urlAlbums = getUrl.photos.getAlbums(need_system=1) requester(urlAlbums, acc.session, 'albums') requester( getUrl.photos.getAll(no_service_albums=0, skip_hidden=1, count=200), acc.session, 'photos') response = requester.request() for r in response: if r[2][0] == 'photos': dataPhotos = json.loads(r[0].text)['response'] self.setPhotos(acc, dataPhotos) elif r[2][0] == 'albums': dataAlbums = json.loads(r[0].text)['response'] self.setAlbums(acc, dataAlbums)
def addVideo(self): requester = HRequester() chil = [ item for item in self.itemList if item.b.checkState() == 2 and item.frozen == 0 ] randomAcc = random.choice(chil) getMainUrl = UrlAPI(randomAcc.token) responseMain = requests.get(getMainUrl.video.get(owner_id='-29573241', count=5), proxies=randomAcc.session.proxies) responseJson = json.loads(responseMain.text)['response']['items'] for video in responseJson: owner_id = video['owner_id'] video_id = video['id'] for acc in chil: getUrl = UrlAPI(acc.token) requester( getUrl.video.add(video_id=video_id, owner_id=owner_id), acc.session, acc.user_id) responseAdd = requester.request() for r in responseAdd: j = json.loads(r[0].text) user_id = r[2][0] if 'response' in j: if j['response'] == 1: pass else: print('Не добавленно', user_id, r[0].text) else: print('Ошибка', user_id, r[0].text) print('----------')
def settingPrivacy(self, acc): requester = HRequester() con = sql.connect('db/db.sqlite3') cur = con.cursor() #Login responseLoginPage = acc.session.get('https://m.vk.com', proxies=acc.session.proxies) soup = BeautifulSoup(responseLoginPage.text) urlLogin = soup.find('form').get('action') acc.session.params.update(email=acc.login) acc.session.params.update({'pass': acc.password}) responseLogin = acc.session.get(urlLogin, allow_redirects=False, proxies=acc.session.proxies) params = ['mail_send', 'profile', 'audios', 'gifts', 'wall_send'] for param in params: self.setting(acc, param) # Close coments under wall post and display walls record getUrl = UrlAPI(acc.token) url1 = getUrl.account.setInfo(name='own_posts_default', value=0) url2 = getUrl.account.setInfo(name='no_wall_replies', value=1) requester(url1, acc.session) requester(url2, acc.session) response = requester.request() for r in response: j = json.loads(r[0].text) if j['response'] == 1: print( 'Успешно включено отображение записей на стене пользователя и закрыты коментарии на стене' ) con.close()
def filing(self): requester = HRequester() for acc in self.chil: getUrl = UrlAPI(acc.token) urlAvatars = getUrl.users.get(fields='photo_50') requester(urlAvatars, acc.session, acc) response = requester.request() for r in response: acc = r[2][0] try: dataAvatars = json.loads(r[0].text)['response'][0] if dataAvatars[ 'photo_50'] != 'https://vk.com/images/camera_50.png': acc.b.setChecked(True) else: acc.b.setChecked(False) except Exception as e: print(repr(e))
class HAddGroup(QWidget): def __init__(self, parent=None, mas=None): super().__init__(parent, Qt.Window) self.ui() self.masSessions = mas self.requester = HRequester() self.btn_send.clicked.connect(self.leaveGroup) self.show() def ui(self): mainLayout = QVBoxLayout(self) self.btn_send = QPushButton('Send') self.btn_send.setFocus() self.line = QLineEdit() mainLayout.addWidget(self.btn_send) mainLayout.addWidget(self.line) self.line.setFocus() def leaveGroup(self): for mas in self.masSessions: session = mas[0] token = mas[1] getUrl = UrlAPI(token) url = getUrl.groups.leave(group_id=self.line.text()) self.requester(url, session) response = self.requester.request() for item in response: try: res = json.loads(item[0].text) if res['response'] == 1: print('Успешно') else: print(res) except: print('Ошибка', item[0].text)
def clearingGroups(self): getUrl = UrlAPI(self.token) requester = HRequester() responseGroups = requests.get(getUrl.groups.get(extended=1), proxies=self.session.proxies) items = json.loads(responseGroups.text)['response']['items'] with open('files/cities', 'r') as f: lines = f.readlines() for item in items: for line in lines: result = re.search(line.lower().strip('\n'), item['name'].lower()) if result: leave = requests.get( getUrl.groups.leave(group_id=item['id']), proxies=self.session.proxies) print(leave.text, item['name'])
class User: def __init__(self, name, token, session): self.name = name self.timeout = 0 self.interval1 = 75 self.interval2 = 95 self.session = session self.getUrl = UrlAPI(token) self.requester = HRequester() self.photoIdsList = [] def run(self): for photo_id in self.photoIdsList: self.like(photo_id) time.sleep(random.randint(self.interval1, self.interval2)) def like(self, photo_id): captcha = False captcha_result = '' captcha_sid = '' while True: owner_id, item_id = photo_id.split('_') if captcha == False: url = self.getUrl.likes.add(type='photo', owner_id=owner_id, item_id=item_id) else: url = self.getUrl.likes.add(type='photo', owner_id=owner_id, item_id=item_id, captcha_sid=captcha_sid, captcha_key=captcha_result) self.requester(url, self.session) response = self.requester.request() for r in response: j = json.loads(r[0].text) try: if 'likes' in j['response']: with open('files/completed', 'a') as file: file.write(str(owner_id) + '\n') print('+', owner_id) return except Exception as e: print(e) print(r[0].text) if 'error' in j: if j['error']['error_code'] == 14: print("Решаем капчу") captcha = Captcha() captcha_result = captcha.solve(self.session, j['error']['captcha_img']) captcha_sid = j['error']['captcha_sid'] if captcha_result == 'error': self.interval = 2000 return else: captcha = True print(self.name, 'Captcha', captcha_result) if j['error']['error_code'] == 15: with open('files/completed', 'a') as file: file.write(str(owner_id) + '\n') print('+', owner_id) return if j['error']['error_code'] == 17: self.interval = 99999 return
def sendRequests(self): otherAccList = [] requester = HRequester() with self.con: cur = self.con.cursor() cur.execute('SELECT * FROM friends') friendsRelation = cur.fetchall() # Function to find relation of users and added in requester def added(acc1, acc2, amountAdded): if acc1.user_id == acc2.user_id: return 'next' elif str(acc1.user_id) + '_' + str(acc2.user_id) in friendsRelation: return 'next' elif str(acc2.user_id) + '_' + str(acc1.user_id) in friendsRelation: return 'next' else: getUrl = UrlAPI(acc.token) requester(getUrl.friends.add(user_id=acc2.user_id), acc1.session, acc1.user_id, acc2.user_id) amountAdded += 1 if amountAdded < self.number_of_additions: return 'amountAdded' if amountAdded == self.number_of_additions: return 'complete' # search for accounts that do not have main names for acc in self.parent.masAccaunts: if acc['name'] in self.mainNames: pass else: otherAccList.append(ItemAcc(self, acc)) # accounts iterate and call function 'added' for acc in self.chil: print(acc) amountAdded = 0 for otherAcc in otherAccList: result = added(acc, otherAcc, amountAdded) print(result) if result == 'complete': break elif result == 'next': continue elif result == 'amountAdded': amountAdded += 1 response = requester.request() successfully = 0 error = 0 for r in response: j = json.loads(r[0].text) user_id1, user_id2 = r[2] print(user_id1, user_id2) if 'response' in j: if j['response'] == 1: successfully += 1 with self.con: cur = self.con.cursor() cur.execute('INSERT INTO friends VALUES(?,?)', (user_id1, user_id2)) self.con.commit() else: print(j) error += 1 else: print(j) error += 1 if error == 0: print('Успешно у всех. Кол-во выбранных:', str(len(self.chil)), 'Кол-во удачно отправленных:', str(successfully / 3)) else: print('Кол-во выбранных:', str(len(self.chil)), 'Кол-во удачно отправленных:', str(successfully / 3), 'Кол-во ошибок', str(error / 3))