1

I just started playing around with python. Recently I stumbled upon web scraping and I thought that it would not be that hard to make a Kahoot (https://kahoot.it/) bot. You may or may not know what I'm talking about. That's not important now. What I need is to create program that would fill out a game id and then a nickname but when I try and run the program I get error.

mechanize._mechanize.FormNotFoundError: no form matching name 'gameId'

import re
import config

from mechanize import Browser

br = Browser()

br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Firefox')]

br.open ("https://kahoot.it/")
br.select_form('gameId')
br.form['game-pin-input'] = '6105440'

This is the form.

<form action="#">
<input name="gameId" type="tel" placeholder="Game PIN" id="game-input" data-functional-selector="game-pin-input" class="sc-dlfnbm lflLbn" autocomplete="off" value="" aria-expanded="false">
<button type="submit" value="Submit" class="enter-button__EnterButton-sc-1o9b9va-0 kfzgPK" data-functional-selector="join-game-pin">Enter</button>
</form>

I even tried finding the form name with a script but i got no return.

import os, subprocess
import re
import mechanize
from bs4 import BeautifulSoup

br = mechanize.Browser()

br.set_handle_robots(False) 
br.addheaders = [('User-agent', 'Firefox')]

br.open ("https://kahoot.it/")
for form in br.forms():
    print (form.name)

Please keep in mind that this is my first time dealing with html and I am not by any means experienced. Thank you.

jan havel
  • 11
  • 3
  • `gameId` is the name of an input element inside the form, not of the form itself. As far as I can see, that form has no name at all. – John Gordon Jan 05 '21 at 01:41
  • How would I then input variable into the form? – jan havel Jan 05 '21 at 01:43
  • When I run your second code sample, `br.forms()` returns an empty list. mechanize thinks that page has no forms at all, likely because they are created dynamically via javascript, which mechanize does not support. – John Gordon Jan 05 '21 at 01:48
  • You'll need to use something that acts like a real browser, such as Selenium. – John Gordon Jan 05 '21 at 01:50

0 Answers0