我試圖做一個kahoot垃圾郵件發送者輸入一個PIN碼和一個用戶名,由用戶決定。我得到一個類型的錯誤,當我運行這段代碼:RoboBrowser獲取類型錯誤'NoneType'對象不可訂閱
import re
from robobrowser import RoboBrowser
#Getting pin number for kahoot
pin = int(input("What is the pin number of the Kahoot?"))
# Getting number of bots to be deployed
number_of_bots = int(input("How many bots would you like?"))
#Getting base name
name = str(input("What would you like your bots' name to be (number will be added to the end of the name)?"))
#counter
counter = 0
#Number on end of name
num = 1
def joinKahoot(pin, number_of_bots, name):
browser = RoboBrowser(history = True)
#Connect to kahoot's website
browser.open("https://kahoot.it/")
pin_form = browser.get_form()
pin_form['inputSession'].value == pin
browser.submit_form(pin_form)
name_form = browser.get_form()
name_form["username"].value == name
browser.submit_form(name_form)
#While counter is less than number_of_bots flood kahoot
while counter < number_of_bots:
joinKahoot(pin, number_of_bots, name)
counter += 1
num += 1
name = name + str(num)
錯誤:
Traceback (most recent call last):
File "C:\Users\Vincent\Documents\Kahoot Spammer V2\flood.py", line 29, in <module>
joinKahoot(pin, number_of_bots, name)
File "C:\Users\Vincent\Documents\Kahoot Spammer V2\flood.py", line 20, in joinKahoot
pin_form['inputSession'].value == pin
TypeError: 'NoneType' object is not subscriptable
我做錯了嗎?
是name_form [「username」]。value == name比較正確的語法,或者你的意思是= – Rosh
@rosh無論哪種方式,我仍然會得到相同的錯誤。 –
這意味着'browser.get_form()'返回'None',然後你試着查找失敗的'None [「username」]''。 –