|
|
|
本帖最后由 czs 于 2019-12-5 17:24 编辑
凿壁借光机场,给自己刷推荐
from selenium import webdriver
from selenium.webdriver.common.keys importKeys
from selenium.webdriver.support.ui importSelect
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui importWebDriverWait
from selenium.webdriver.support importexpected_conditions as EC
import random
import requests
import urllib.request
from bs4 import BeautifulSoup
import base64
from PIL import Image
import numpy as np
from selenium.webdriver import ActionChains
import time
import PIL.Image as image
from PIL import ImageChops, PngImagePlugin
#依赖python环境,chrome浏览器以及webdriver,依赖包参考报错,推荐anaconda
INIT_LEFT = 60
BORDER = 6
table = []
for i in range(256):
if i < 50:
table.append(0)
else:
table.append(1)
def is_pixel_equal(image1, image2, x, y):
pixel1 = image1.load()[x, y]
pixel2 = image2.load()[x, y]
threshold =60
if abs(pixel1[0] - pixel2[0]) < threshold and abs(pixel1[1] -pixel2[1]) < threshold and abs(pixel1[2] - pixel2[2]) < threshold:
return True
else:
return False
def compute_gap(img1, img2):
img1 = img1.convert("RGB")
img2 = img2.convert("RGB")
diff = ImageChops.difference(img1, img2)
diff = diff.convert("L")
diff = diff.point(table,'1')
left = 43
for w in range(left, diff.size[0]):
lis = []
for h in range(diff.size[1]):
if diff.load()[w, h] == 1:
lis.append(w)
if len(lis) > 5:
return w
def ease_out_quad(x):
return 1 - (1 - x) * (1 - x)
def ease_out_quart(x):
return 1 - pow(1 - x, 4)
def ease_out_expo(x):
if x == 1:
return 1
else:
return 1 - pow(2, -10 * x)
def get_track(distance, seconds,ease_func):
tracks = [0]
offsets = [0]
for t in np.arange(0.0, seconds, 0.1):
ease = ease_func
offset = round(ease(t / seconds) * distance)
tracks.append(offset - offsets[-1])
offsets.append(offset)
return tracks
i=0
while i< 10: #获取临时邮箱,仅针对此网站,可设置注册次数#
try:
r = requests.get("https://10minutemail.net", verify=True)
r.encoding = 'utf-8'
soup = BeautifulSoup(r.text, 'html.parser')
print(soup.input["value"])
driver = webdriver.Chrome()
driver.get("https://hi.ssrcf.top/auth/register") #此处为注册地址,该站域名会更换,所以此处需更换#
driver.find_element_by_xpath('//input[@id="name"]').send_keys('***') #名称,自定义#
driver.find_element_by_xpath('//input[@id="email"]').send_keys(soup.input["value"])
driver.find_element_by_xpath('//input[@id="passwd"]').send_keys('********') #密码#
driver.find_element_by_xpath('//input[@id="repasswd"]').send_keys('********') #重复密码#
driver.find_element_by_xpath('//button[@id="imtype"]').click()
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.LINK_TEXT, "QQ"))).click()
driver.find_element_by_xpath('//input[@id="wechat"]').send_keys(random.randint(666666,9999999999))
driver.find_element_by_xpath('//input[@id="code"]').send_keys('****') #邀请码#
button=WebDriverWait(driver,5).until(EC.element_to_be_clickable((By.CLASS_NAME, 'geetest_radar_tip')))
button.click()
im=WebDriverWait(driver,5).until(EC.presence_of_element_located((By.CSS_SELECTOR,'.geetest_canvas_bg')))
im.screenshot('captcha.png')
JS ='returndocument.getElementsByClassName("geetest_canvas_fullbg")[0].toDataURL("image/png");'
im_info = driver.execute_script(JS)
im_base64 = im_info.split(',')[1]
captcha1 = base64.b64decode(im_base64)
with open('captcha1.png','wb') as f:
f.write(captcha1)
JS ='return document.getElementsByClassName("geetest_canvas_bg")[0].toDataURL("image/png");'
im_info = driver.execute_script(JS)
im_base64 = im_info.split(',')[1]
captcha2 = base64.b64decode(im_base64)
with open('captcha2.png','wb') as f:
f.write(captcha2)
image1 = Image.open('captcha1.png')
image2 = Image.open('captcha2.png')
gap=compute_gap(image1,image2)
print('缺口位置' , gap)
gap -= BORDER
track = get_track(gap,0.3,ease_out_quart)
print('滑动轨迹:',track)
slider=WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR,'.geetest_slider_button')))
ActionChains(driver).click_and_hold(slider).perform()
for x in track:
ActionChains(driver).move_by_offset(xoffset=x, yoffset=0).perform()
time.sleep(0.1)
ActionChains(driver).release().perform()
time.sleep(2)
driver.find_element_by_xpath('//button[@id="tos"]').send_keys(Keys.ENTER)
time.sleep(2)
driver.find_element_by_xpath('//button[@id="reg"]').click()
flag=1
while flag==1:
try:
time.sleep(5)
driver.find_element_by_xpath('//button[@id="tos"]').send_keys(Keys.ENTER)
time.sleep(2)
driver.find_element_by_xpath('//button[@id="reg"]').click()
except:
flag=0
driver.close()
i=i+1
print(i)
except:
driver.quit()
保存为.py文件,安装python环境使用
ssr https://sub.sswow.xyz/link/NCGkw0iPi4NMUABU?mu=1
大概15天,VIP5,
还有天天向上也可以白嫖? 我的推广链接https://edu.lovessr.top/register?aff=96897
|
|