Attributeerror: 'spider' Object Has No Attribute 'table'
I'm working with scrapy. I have a spider that starts with: class For_Spider(Spider): name = 'for' # table = 'hello' # creating dummy attribute. will be overwritten def
Solution 1:
table will work because it is a class attribute of For_Spider and self.table is just inside the function scope. self indicates the instance itself, so in that case inside the function you don't need to use it (unless you define it in __init__).
If you'll try defining self.table outside the function scope you'll get an error.
Also, try using __dict__ on both classes to see their attributes and functions
With table commented:
{'doc': None, 'start_requests': , 'name': 'for', 'module': 'builtins'})
As you can see, no table attribute
With table not commented:
{'doc': None, 'start_requests': , 'table': 'hello', 'name': 'for', 'module': 'builtins'})
I hope that was clear :>
Post a Comment for "Attributeerror: 'spider' Object Has No Attribute 'table'"