Last active
August 29, 2015 14:06
-
-
Save Alex0007/2450b4d51053a1723aad to your computer and use it in GitHub Desktop.
ходим по ловушкам для гостей вк UPD. И ПИШЕМ ХУЙНЮ В АСК))
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
import string | |
import time | |
import re | |
import random | |
import vk_api | |
import requests | |
# in F12 mode in Chrome catch requst from https://vk.com/app4392060#askfm&aleksashaomg | |
# to that site and remove 'aleksashaomg' from back | |
url = 'https://s8lqxeqp2s.ru/?api_url=https://api.vk.com/api.php&api_id=4392060&api_settings=0&vieweasdasdasdcxzc' | |
# список вопросов | |
questions = [] | |
cookies = None | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36', | |
# 'Referer': 'http://ask.fm/', | |
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', | |
# 'Accept-Encoding': 'gzip,deflate,sdch', | |
# 'Accept-Language': 'ru,en-US;q=0.8,en;q=0.6', | |
# 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' | |
} | |
vk = vk_api.VkApi() | |
current_proxy = None | |
token = None | |
counter = 0 | |
def read_file_to_array(file_desc): | |
file_desc.seek(0) | |
array = [line.strip() for line in file_desc] | |
return array | |
def read_proxies(): | |
file = open("proxies.txt", "a+") | |
proxies = read_file_to_array(file) | |
file.close() | |
return proxies | |
def search_askfm(startfrom=''): | |
global next_from, again | |
askfm_ids = [] | |
values = {'q': 'askfm', 'count': 10} # , 'start_from': startfrom} | |
response = vk.method('newsfeed.search', values) | |
try: | |
next_from = response['next_from'] | |
except: | |
again = True | |
for item in response['items']: | |
try: | |
to_append = str.split(item['attachments'][0]['link']['url'], '/')[-1] | |
except: | |
to_append = str.split(item['text'], '/')[-1] | |
to_append = str.split(to_append, ' ')[0] | |
try: | |
to_append.encode('latin-1') | |
askfm_ids.append(to_append) | |
except: | |
print('encode error') | |
return askfm_ids | |
def go_askfm(ids): | |
global counter | |
counter = 0 | |
for item in ids: | |
if counter == 8: | |
print("8 SUCCESSFUL POSTS FROM PROXY, CHANGING") | |
get_auth_token() | |
counter = 0 | |
counter += 1 | |
r = requests.get(url + item) | |
print('Visit: ', str(item)) | |
# asking questions | |
ask_question(id=item, question=(random.choice(questions))) | |
def ask_question(id="", question=""): | |
global cookies, headers, token | |
temp_header = headers | |
try: | |
data = 'question[question_text]=' + ''.join( | |
random.choice(string.ascii_uppercase + string.digits) for _ in range(random.randint(1, 3))) \ | |
+ ' /' + question + '&authenticity_token=' + token | |
data = data.encode('utf8') | |
resp = requests.post('http://ask.fm/' + id + '/questions/create', data=data, cookies=cookies, | |
headers=temp_header, | |
proxies=current_proxy, timeout=6) | |
if re.findall(r'Captcha.regenerate', resp.text).__len__() == 0: | |
print('Question: ', id) | |
time.sleep(random.randint(1, 6)) | |
else: | |
print('Error: captcha needed') | |
print('Trying to change proxy') | |
get_auth_token() | |
ask_question(id, question) | |
return | |
except Exception as inst: | |
print(inst) | |
print('some error here. Giving new token and trying to ask again') | |
get_auth_token() | |
pass | |
def get_auth_token(): | |
global cookies, headers, current_proxy, token, counter | |
counter = 0 | |
result = None | |
print("TRYING TO GET TOKEN") | |
while not result: | |
cookies = None | |
# change_identity() | |
# current_proxy = {"http": "http://localhost:8118"} | |
if proxies.__len__() > 0: | |
current_proxy = random.choice(proxies) | |
current_proxy = {"http": "http://" + current_proxy} | |
print('USING PROXY ' + current_proxy['http']) | |
else: | |
current_proxy = '' | |
print('USING DIRECT CONNECTION NOW') | |
try: | |
resp = requests.get('http://ask.fm/', headers=headers, proxies=current_proxy, timeout=6) | |
cookies = resp.cookies | |
result = re.findall(r'\'.*\'', | |
re.findall(r'encodeURIComponent\(\'.*\'\)', | |
resp.text)[0])[0].replace('\'', '') | |
except: # banned on askfm or proxy is broken | |
result = None | |
print("ANOTHER TRY..") | |
token = result | |
print("NEW TOKEN IS ", result) | |
time.sleep(random.randint(0, 2)) | |
proxies = read_proxies() | |
get_auth_token() | |
while True: | |
go_askfm(search_askfm()) | |
print('Waiting now..') | |
time.sleep(20 + random.randint(0, 12)) | |
# ask_question('Alex0007',random.choice(questions)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment