python斜纹模块提交表单

2024-09-30 04:40:04 发布

您现在位置:Python中文网/ 问答频道 /正文

你好,我目前正在尝试做一个机器人注册自己的网站。 我的代码如下:

from twill.commands import fv, code, follow, go, submit, browser
from time import sleep
import random

emailProviders = ["@yahoo.com", "@web.de", "@gmail.com"]

def userChoice():
        invLink = raw_input("[ZenGamingBot] Enter your invitation Link-> ")
        userName = raw_input("[ZenGamingBot] Enter a Username for the Bot-> ")
        count = 0
        while True:
                count += 1
                regBot(invLink, userName, count)

def regBot(invLink, userName, count):
        invLink = invLink.strip("http://")
        invLink = "http://" + invLink
        username = userName + str(count)
        email = userName + str(count) + random.choice(emailProviders)
        password = userName + str(count) + "345"

        go(invLink)
        code("200")
        print "[ZenGamingBot] Loaded Website successfully!"
        sleep(1)
        follow("ENTER NOW")
        url=browser.get_url()
        print url
        fv("2", "fos_user_registration_form_username", username)
        fv("2", "fos_user_registration_form_email", email)
        fv("2", "fos_user_registration_form_plainPassword_first", password)
        submit('Enter')

        print "[ZenGamingBot] Successfully registerd Bot #" + str(count) + "\n "
        print "Username: " + username + "\n"
        print "Email: " + email + "\n"
        print "Password: " + password + "\n"

def main():
        userChoice()
main()

这个机器人是在http://zengaming.co/register/注册的,它会转到邀请代码的链接并注册。我得到以下输出:

^{pr2}$

Tags: importhttpurlemaildefcountusernamepassword

热门问题