您好我正在尝试制作一个在网站上注册的机器人。 我的守则如下:
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()
此Bot用于在注册,它会转到邀请码的链接并注册。我得到以下输出:
[ZenGamingBot] Enter your invitation Link-> http://zengaming.co/r?zen=1179068
[ZenGamingBot] Enter a Username for the Bot-> BotTestName
==> at http://zengaming.co/welcome
[ZenGamingBot] Loaded Website successfully!
==> at http://zengaming.co/register/
Note: submit is using submit button: name="None", value="Enter"
Traceback (most recent call last):
File "ZenGamingBot.py", line 39, in <module>
main()
File "ZenGamingBot.py", line 38, in main
userChoice()
File "ZenGamingBot.py", line 13, in userChoice
regBot(invLink, userName, count)
File "ZenGamingBot.py", line 30, in regBot
submit('Enter')
File "/home/invasi0nz/.local/lib/python2.7/site-packages/twill/commands.py", line 359, in submit
browser.submit(submit_button)
File "/home/invasi0nz/.local/lib/python2.7/site-packages/twill/browser.py", line 393, in submit
headers=headers
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 508, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 451, in request
prep = self.prepare_request(req)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 382, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 304, in prepare
self.prepare_url(url, params)
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 362, in prepare_url
to_native_string(url, 'utf8')))
requests.exceptions.MissingSchema: Invalid URL '/register/': No schema supplied. Perhaps you meant http:///register/?