How do I use this? TypeError: 'NoneType' object does not support item assignment - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How do I use this? TypeError: 'NoneType' object does not support item assignment (/thread-17035.html) |
How do I use this? TypeError: 'NoneType' object does not support item assignment - ejected - Mar-25-2019 form['user_password'] = config.DATACOUP_PASSWORDI want to put my own password in there. WITHOUT the config.py file So I want to just put the psasword directly into the script. I tried these but they don't work: form['user_login'] = myuser123 form['user_login'] = "myuser123" form['user_login'] = 'myuser123'I get this same error for all the above: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'NoneType' object does not support item assignmentAlso bonus question: How do I import the config.py file? I can't simply do import config.py because it's not in the same directory. Is there a simple way to import it if its not in the same directory? RE: How do I use this? - Yoriz - Mar-25-2019 the variable form has been aligned to None, you don't show where form come from. >>> form = None >>> form['user_login'] = 'myuser123' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'NoneType' object does not support item assignment >>> RE: How do I use this? - ejected - Mar-25-2019 (Mar-25-2019, 08:44 PM)Yoriz Wrote: the variable form has been aligned to None, you don't show where form come from. I used this: >>> form = br.get_form() >>> form['user_login'] = 'myuser123' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'NoneType' object does not support item assignmentIt still gives the same error. RE: How do I use this? TypeError: 'NoneType' object does not support item assignment - Yoriz - Mar-25-2019 br.get_form()is returning None what is br, do you see a pattern here, if you don't reveal enough code we can't reveal an answer RE: How do I use this? TypeError: 'NoneType' object does not support item assignment - ejected - Mar-25-2019 Sorry, here is the entire code: I just took the link/user/pass info out import re import config from robobrowser import RoboBrowser br = RoboBrowser() br.open("mylink.com") form = br.get_form() form['user_login'] = 'myuser' form['user_password'] = 'mypass' br.submit_form(form) RE: How do I use this? TypeError: 'NoneType' object does not support item assignment - nilamo - Mar-25-2019 Try specifying which form you want. Currently, it looks like no forms are found. https://robobrowser.readthedocs.io/en/latest/readme.html Quote:import re from robobrowser import RoboBrowser # Browse to Rap Genius browser = RoboBrowser(history=True) browser.open('http://rapgenius.com/') # Search for Queen form = browser.get_form(action='/search') form # <RoboForm q=> form['q'].value = 'queen' browser.submit_form(form) RE: How do I use this? TypeError: 'NoneType' object does not support item assignment - Yoriz - Mar-25-2019 I've never used robobrowser but i looked at the docs Quote:get_form(id=None, *args, **kwargs)[source]So no BeautifulSoup tag has been found, maybe you should be passing in some sort of argument for it to find something. RE: How do I use this? TypeError: 'NoneType' object does not support item assignment - ejected - Mar-25-2019 I did the same code but with facebook.com/login and it worked fine. I'm guessing it has something to do with the username input code part? Cause on facebook the input name/id are the same its: "email" But the website im trying to put the input in they are different and the name has [login] inside the code... This is the html part on the website: <input class="form-control string required a-input db w-100 f16 ph3 ba bg-light-primary text br1 outline-0 bg-input input-reset mb3 pv08 lh-normal" type="text" autocomplete="on" autocapitalize="off" autocorrect="off" autofocus="autofocus" placeholder="Nickname or Email" name="user[login]" id="user_login">see how to name="user[login]" has [login] in it? Is that the problem? I tried this: form['user[login]'] = 'myuser' form['user_login'] = 'myuser' And neither are working. Maybe the problem is that the input name "user[login]" doesn't work because it has [ ] in it? Idk. I'm new to python would that be the problem? Is there any other way to log into a site? Without using RoboBrowser? RE: How do I use this? TypeError: 'NoneType' object does not support item assignment - ejected - Mar-26-2019 (Mar-25-2019, 09:26 PM)Yoriz Wrote: So no BeautifulSoup tag has been found, maybe you should be passing in some sort of argument for it to find something. How do I do this? Sorry, I'm very new to Python can you dumb it down a bit lol RE: How do I use this? TypeError: 'NoneType' object does not support item assignment - ejected - Mar-26-2019 Nvm found another way to do it. I used Selenium with XPATH to login. Step 1 complete. :) Now I gotta learn how to scrape it |