Python Forum
How do I use this? TypeError: 'NoneType' object does not support item assignment
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I use this? TypeError: 'NoneType' object does not support item assignment
#1
form['user_password'] = config.DATACOUP_PASSWORD
I 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 assignment
Also 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?
Reply
#2
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
>>>
Reply
#3
(Mar-25-2019, 08:44 PM)Yoriz Wrote: 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
>>>

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 assignment
It still gives the same error.
Reply
#4
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
Reply
#5
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)
Reply
#6
Try specifying which form you want. Currently, it looks like no forms are found.

https://robobrowser.readthedocs.io/en/la...eadme.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)
Reply
#7
I've never used robobrowser but i looked at the docs
Quote:get_form(id=None, *args, **kwargs)[source]
Find form by ID, as well as standard BeautifulSoup arguments.

Parameters: id (str) – Form ID
Returns: BeautifulSoup tag if found, else None
So no BeautifulSoup tag has been found, maybe you should be passing in some sort of argument for it to find something.
Reply
#8
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?
Reply
#9
(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
Reply
#10
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 274 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 456 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 679 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 922 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,262 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,385 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  TypeError: 'float' object is not callable #1 isdito2001 1 1,046 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  TypeError: a bytes-like object is required ZeroX 13 3,842 Jan-07-2023, 07:02 PM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,375 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov
  API Post issue "TypeError: 'str' object is not callable" makeeley 2 1,834 Oct-30-2022, 12:53 PM
Last Post: makeeley

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020