0

I'm trying to create a simple login into a "Kahoot!" quiz . First thing i'm trying to do is load from "https://kahoot.it/#/" JSON objects so i could fill the form in it (i tried to fill the form using 'mechenize' but its seems to support only html forms). when im running the next script im getting exception that json could not be decoded:

import urllib, json
url = "https://kahoot.it/#/"
response = urllib.urlopen(url)
data = json.loads(response.read())
print data

output:

ValueError: No JSON object could be decoded

Any ideas? , Thanks.

asked Nov 28, 2015 at 12:10

1 Answer 1

1

type(response.read()) is str, representing the HTML of the page. Obviously it's not a valid JSON therefore you are getting that error.

EDIT If you are trying to login to that page, it is possible with selenium:

from selenium import webdriver
url = "https://kahoot.it/#/"
driver = webdriver.Chrome() # or webdriver.Firefox()
driver.get(url)
# finding the text field and 'typing' the game pin
driver.find_element_by_xpath('//*[@id="inputSession"]').send_keys('your_game_pin')
# finding and clicking the sumbit button
driver.find_element_by_xpath('/html/body/div[3]/div/div/div/form/button').click()
answered Nov 28, 2015 at 12:16
Sign up to request clarification or add additional context in comments.

3 Comments

so what is the right way to load json from this website?
In order to load JSON from the website, it needs to send you a response containing JSON. It doesn't seem to be the case. If you are trying to login to that page, it is possible with selenium.
Thank you, any other idea how can i get the form so i could fill it with python?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.