跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 发现一个不错的python脚本,就是运行有点麻烦
未分類
29 1 月 2020

发现一个不错的python脚本,就是运行有点麻烦

etc 大佬有话说 :

发现一个不错的python脚本,就是运行有点麻烦

没折腾明白

https://www.52pojie.cn/thread-996573-1-1.html

# coding = utf-8
# 以下代码仅供参考讨论,请勿用作其它非法用途
# www.52pojie.cn

# python 3.7
# @Author:iknew

from bs4 import BeautifulSoup as bs
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import selenium
import time
import csv
import random
from mock_useragent import UserAgent

‘’‘1. 设置临时邮箱
2. 填写注册信息
3. 等待验证
4. 填写验证码
5. 完成注册
’‘’

def sign_up(name,pwd):
    global element
    email = name + ‘@t.odmail.cn’

    url = ‘https://t.odmail.cn/’
    code = ”
    browser.get(url)
    time.sleep(3)
    try:
      browser.implicitly_wait(15)
      element = browser.find_element_by_id(‘customShortid’)
    except selenium.common.exceptions.NoSuchElementException:
      print(‘网页加载不出来’)
      sign_up(name,pwd)
    element.click()
    browser.implicitly_wait(5)
    browser.find_element_by_id(‘shortid’).send_keys(name)
    browser.implicitly_wait(5)
    element.click()
    print(’email set up …’)
    # browser.execute_script(js)
    js = ‘window.open("https://signup.microsoft.com/signup/index?sku=faculty");’
    browser.execute_script(js)
    windows = browser.window_handles
    browser.switch_to.window(windows)
    browser.implicitly_wait(30)
    browser.find_element_by_id("StepsData_Email").send_keys(email)
    browser.implicitly_wait(2)
    browser.find_element_by_class_name(‘mpl-button-box-text’).click()
    browser.switch_to.window(windows)
    print(‘waiting for verification code …’)

    while code == ”:
      time.sleep(3)
      browser.find_element_by_id(‘maillist’)
      r = browser.find_element_by_id(‘maillist’).text
      code = r
    print(‘Got the verification code:{}n’.format(code))
    browser.implicitly_wait(10)
    #切换窗口到注册页面填写信息、验证码:
    browser.switch_to.window(windows)
    browser.implicitly_wait(20)
    try:   
      element = browser.find_element_by_class_name(‘last-name’)
      element.send_keys(‘o’)
    except selenium.common.exceptions.ElementNotInteractableException: browser.quit()
    browser.implicitly_wait(5)
    browser.find_element_by_class_name(‘first-name’).send_keys(‘o’)
    browser.implicitly_wait(5)
    browser.find_element_by_id(‘Password’).send_keys(pwd)
    browser.implicitly_wait(5)
    browser.find_element_by_id(‘RePassword’).send_keys(pwd)
    browser.implicitly_wait(5)
    browser.find_element_by_id(‘SignupCode’).send_keys(code)
    browser.implicitly_wait(10)
    browser.find_element_by_class_name(‘mpl-button-box-text’).click()
    print(‘注册的账号密码:{0},{1},验证码:{2}n’.format(email,pwd,code))
    try:   
      browser.implicitly_wait(20)
      element = browser.find_element_by_class_name(‘ms-fcl-tp’)
      element.click()
    except selenium.common.exceptions.StaleElementReferenceException:
      browser.refresh()
    return

’‘’1. 注册名称设置2. selenium参数设置
3. 调用sign_up()
4. 注册后的账号密码写入文件
”’
def main():
    global browser
    n = 0
    for i in range(1,1000):#   设置注册ID范围,程序中断需要手动修改起始位置…      
      name = ‘这里填你想要的名称’+str(i)
      pwd = ‘One.’+str(random.randint(1000,9990))

      t = time.time()
      agent = UserAgent.random_chrome
      options = Options()
      options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])#避免一些无关紧要的报错
      options.add_argument(‘–user-agent={}’.format(agent))
      options.add_argument(‘–ignore-certificate-errors’)
      options.add_argument(‘–ignore-ssl-errors’)
      options.add_argument(‘–start-maximized’)   #窗口最大化,感觉不太需要
      options.add_argument(‘–window-size=1920,1080’)#设置窗口大小
      options.add_argument(‘–headless’)          # 后台运行,可注释掉查看自动注册流程
      browser = webdriver.Chrome(chrome_options= options)
#调用sign_up函数注册
      user = sign_up(name,pwd)
      f = open(‘onedrive.csv’,’a’,newline=”)
      writer = csv.writer(f)
      f.seek(0,2)
      writer.writerow(user)
      f.close()
      n += 1
      print(‘Time now:{0}’.format(time.strftime("%Y%m%d %X", time.localtime())))
      print(‘注册第 "{}"个用时:{:.2f} 秒’.format(n,time.time()-t),end=’n———————‘)
      browser.quit()
      if n % 20 == 0 :
            print(‘休息10分钟,避免IP被封’)
            time.sleep(600)

if __name__ == "__main__":
    main()

h2o 大佬有话说 :

52pojie迟早封站

wolfewong 大佬有话说 :

粗略看了一下,就是用临时邮箱批量注册onedrive,如果临时邮箱是自己的还好,如果是别人的,相当于薅羊毛了,很容易薅死羊的

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具