Skip to content

Commit 4b4a8eb

Browse files
authored
docs: update code example for Scrapy guide (#410)
1 parent 91c4d7a commit 4b4a8eb

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

docs/02_guides/code/scrapy_project/src/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

3-
from twisted.internet import asyncioreactor
3+
from scrapy.utils.reactor import install_reactor
44

55
# Install Twisted's asyncio reactor before importing any other Twisted or
66
# Scrapy components.
7-
asyncioreactor.install() # type: ignore[no-untyped-call]
7+
install_reactor('twisted.internet.asyncioreactor.AsyncioSelectorReactor')
88

99
import os
1010

docs/02_guides/code/scrapy_project/src/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
ROBOTSTXT_OBEY = True
66
SPIDER_MODULES = ['src.spiders']
77
TELNETCONSOLE_ENABLED = False
8+
# Do not change the Twisted reactor unless you really know what you are doing.
89
TWISTED_REACTOR = 'twisted.internet.asyncioreactor.AsyncioSelectorReactor'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .title import TitleSpider
2+
3+
__all__ = ['TitleSpider']

docs/02_guides/code/scrapy_project/src/spiders/title.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if TYPE_CHECKING:
1111
from collections.abc import Generator
1212

13-
from scrapy.responsetypes import Response
13+
from scrapy.http.response import Response
1414

1515

1616
class TitleSpider(Spider):

0 commit comments

Comments
 (0)