SCP02: Invalid allowed_domains entry

What it does

Finds URLs or domains with a port in allowed_domains.

Why is this bad?

The allowed_domains attribute should contain domain names only. A domain that carries a port never matches any request, so it is silently not allowed.

Example

import scrapy


class MySpider(scrapy.Spider):
    name = "myspider"
    allowed_domains = ["https://toscrape.com/", "127.0.0.1:8080"]

Use instead:

import scrapy


class MySpider(scrapy.Spider):
    name = "myspider"
    allowed_domains = ["toscrape.com", "127.0.0.1"]

Fix

This rule is automatically fixable with the --fix command-line option: each value is replaced with its bare domain.