1

I'm writing a spider on Scrapy splash and I'm starting to get this error:

File "C:\Users\Name\PycharmProjects\splash\project\project\spiders\scrapy.py", line 5
start_urls = [
             ^
IndentationError: unindent does not match any outer indentation level

Here are the code lines where I get it:

import scrapy
from scrapy_splash import SplashRequest
class ScrapySpider(scrapy.Spider):
    name = "spide1"
    start_urls = [
                'link1',
                'link2', 
                etc

Why am I getting this mistake and how can I fix it?

B. Go
  • 1,436
  • 4
  • 15
  • 22
Кевин
  • 187
  • 1
  • 9
  • where did you put the ], and try to move the links left to the 9th char (2nd level of indentation) and or move the [ and ] on the first and last lines until it works. In Python indentations have to be exactly met! – B. Go Dec 16 '19 at 22:18

1 Answers1

1

The problem was two spaces before def

After adding 2 spaces - problem has been solved

Кевин
  • 187
  • 1
  • 9
  • This explanation does not make any sense. It does not say `def` anywhere in your example code. The problem - revealed by carefully checking the [raw source of your original attempt at the post](https://stackoverflow.com/revisions/7eafdb62-57ec-40a3-be3f-fe02cb57db59/view-source) - is that you used a tab before `name = "spide1"`, but spaces before `start_urls = [`. – Karl Knechtel Jul 14 '23 at 20:29