-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from Lukas0907/fixes
Fixes related to caching, LWN.net and various improvements
- Loading branch information
Showing
34 changed files
with
376 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import logging | ||
|
||
# Feeds configuration populated by an optional feeds configuration file. | ||
FEEDS_CONFIG = {} | ||
|
||
# Low level settings intended for scrapy. | ||
# Please use feeds.cfg to configure feeds. | ||
|
||
BOT_NAME = "feeds" | ||
SPIDER_MODULES = ["feeds.spiders"] | ||
NEWSPIDER_MODULE = "feeds.spiders" | ||
|
||
# Don't overwhelm sites with requests. | ||
CONCURRENT_REQUESTS_PER_DOMAIN = 2 | ||
DOWNLOAD_DELAY = 0.25 | ||
|
||
# Disable telnet | ||
TELNETCONSOLE_ENABLED = False | ||
|
||
# Custom item pipeline | ||
ITEM_PIPELINES = { | ||
"feeds.pipelines.AtomAutogenerateFieldsPipeline": 100, | ||
"feeds.pipelines.AtomCheckRequiredFieldsPipeline": 110, | ||
"feeds.pipelines.AtomExportPipeline": 400, | ||
} | ||
|
||
SPIDER_MIDDLEWARES = { | ||
"feeds.spidermiddlewares.FeedsHttpErrorMiddleware": 51, | ||
"feeds.spidermiddlewares.FeedsHttpCacheMiddleware": 1000, | ||
} | ||
|
||
DOWNLOADER_MIDDLEWARES = { | ||
"feeds.downloadermiddlewares.FeedsHttpCacheMiddleware": 900, | ||
"scrapy.downloadermiddlewares.httpcache.HttpCacheMiddleware": None, | ||
} | ||
|
||
HTTPCACHE_ENABLED = False | ||
HTTPCACHE_STORAGE = "feeds.extensions.FeedsCacheStorage" | ||
HTTPCACHE_POLICY = "scrapy.extensions.httpcache.DummyPolicy" | ||
HTTPCACHE_DIR = "cache" | ||
# We cache everything and delete cache entries (and every parent request) during | ||
# cleanup. | ||
HTTPCACHE_IGNORE_HTTP_CODES = [] | ||
|
||
# Default user agent. Can be overriden in feeds.cfg. | ||
USER_AGENT = "feeds (+https://github.com/nblock/feeds)" | ||
|
||
# Set default level to info. | ||
# Can be overriden with --loglevel parameter. | ||
LOG_LEVEL = logging.INFO | ||
|
||
# Stats collection is disabled by default. | ||
# Can be overriden with --stats parameter. | ||
STATS_CLASS = "scrapy.statscollectors.DummyStatsCollector" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from scrapy.downloadermiddlewares.httpcache import HttpCacheMiddleware | ||
from scrapy import signals | ||
|
||
|
||
class FeedsHttpCacheMiddleware(HttpCacheMiddleware): | ||
@classmethod | ||
def from_crawler(cls, crawler): | ||
o = super().from_crawler(crawler) | ||
crawler.signals.connect(o.item_dropped, signal=signals.item_dropped) | ||
return o | ||
|
||
def item_dropped(self, item, response, exception, spider): | ||
self.storage.item_dropped(item, response, exception, spider) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.