Update black version and fix minor typos and punctuations

This commit is contained in:
pankaj1707k 2023-02-03 11:52:20 +05:30
parent 280cd6ce71
commit 03f32c018f
No known key found for this signature in database
GPG Key ID: 6757E896F6BC635E
14 changed files with 8 additions and 29 deletions

View File

@ -21,4 +21,4 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies:
- black==22.12.0
- black==23.1.0

View File

@ -240,7 +240,6 @@ higher) in your spider:
.. code-block:: python
class MySpider(CrawlSpider):
name = "myspider"
download_delay = 2

View File

@ -20,7 +20,7 @@ In order to show you what Scrapy brings to the table, we'll walk you through an
example of a Scrapy Spider using the simplest way to run a spider.
Here's the code for a spider that scrapes famous quotes from website
https://quotes.toscrape.com, following the pagination
https://quotes.toscrape.com, following the pagination:
.. code-block:: python

View File

@ -635,7 +635,7 @@ A shortcut for creating Requests
--------------------------------
As a shortcut for creating Request objects you can use
:meth:`response.follow <scrapy.http.TextResponse.follow>`
:meth:`response.follow <scrapy.http.TextResponse.follow>`:
.. code-block:: python

View File

@ -132,8 +132,6 @@ Settings API
precedence over lesser ones when setting and retrieving values in the
:class:`~scrapy.settings.Settings` class.
.. highlight:: python
.. code-block:: python
SETTINGS_PRIORITIES = {

View File

@ -356,7 +356,6 @@ HttpAuthMiddleware
class SomeIntranetSiteSpider(CrawlSpider):
http_user = "someuser"
http_pass = "somepass"
http_auth_domain = "intranet.example.com"

View File

@ -90,7 +90,6 @@ contain a price:
class PricePipeline:
vat_factor = 1.15
def process_item(self, item, spider):
@ -150,7 +149,6 @@ method and how to clean up the resources properly.
class MongoPipeline:
collection_name = "scrapy_items"
def __init__(self, mongo_uri, mongo_db):

View File

@ -201,7 +201,6 @@ Item Loaders are declared using a class definition syntax. Here is an example:
class ProductLoader(ItemLoader):
default_output_processor = TakeFirst()
name_in = MapCompose(str.title)

View File

@ -117,7 +117,6 @@ instance, which can be accessed and used like this:
class MySpider(scrapy.Spider):
name = "myspider"
start_urls = ["https://scrapy.org"]
@ -136,7 +135,6 @@ Python logger you want. For example:
class MySpider(scrapy.Spider):
name = "myspider"
start_urls = ["https://scrapy.org"]

View File

@ -321,7 +321,7 @@ It receives a :exc:`~twisted.python.failure.Failure` as first parameter and can
be used to track connection establishment timeouts, DNS errors etc.
Here's an example spider logging all errors and catching some specific
errors if needed
errors if needed:
.. code-block:: python
@ -386,7 +386,7 @@ Accessing additional data in errback functions
In case of a failure to process the request, you may be interested in
accessing arguments to the callback functions so you can process further
based on the arguments in the errback. The following example shows how to
achieve this by using ``Failure.request.cb_kwargs``
achieve this by using ``Failure.request.cb_kwargs``:
.. code-block:: python
@ -593,7 +593,6 @@ URL canonicalization or taking the request method or body into account:
class RequestFingerprinter:
cache = WeakKeyDictionary()
def fingerprint(self, request):
@ -635,7 +634,6 @@ request fingerprinter:
class RequestFingerprinter:
cache = WeakKeyDictionary()
def fingerprint(self, request):

View File

@ -320,8 +320,8 @@ Examples:
>>> response.css("img::text").getall()
[]
is means ``.css('foo::text').get()`` could return None even if an element
ists. Use ``default=''`` if you always want a string:
This means ``.css('foo::text').get()`` could return None even if an element
exists. Use ``default=''`` if you always want a string:
.. code-block:: pycon

View File

@ -134,6 +134,7 @@ Custom Processor and External Callback
# Using external callbacks
#
# Custom Processor
def filter_today_links(requests):
# only crawl today links

View File

@ -79,7 +79,6 @@ A typical application of LegSpider's is to build Link Extractors. For example:
class MySpider(LegSpider):
legs = [RegexHtmlLinkExtractor()]
url_regexes_to_follow = ["/product.php?.*"]
@ -128,7 +127,6 @@ Another example could be to build a callback dispatcher based on rules:
class MySpider(LegSpider):
legs = [CallbackRules()]
callback_rules = {
"/product.php.*": "parse_product",
@ -154,7 +152,6 @@ Another example could be for building URL canonicalizers:
class MySpider(LegSpider):
legs = [CanonicalizeUrl()]
canonicalization_rules = ["sort-query-args", "normalize-percent-encoding", ...]
@ -178,7 +175,6 @@ certain fields:
class MySpider(LegSpider):
legs = [ItemIdSetter()]
id_field = "guid"
id_fields_to_hash = ["supplier_name", "supplier_id"]
@ -196,7 +192,6 @@ Here's an example that combines functionality from multiple leg spiders:
#!python
class MySpider(LegSpider):
legs = [RegexLinkExtractor(), ParseRules(), CanonicalizeUrl(), ItemIdSetter()]
url_regexes_to_follow = ["/product.php?.*"]

View File

@ -170,7 +170,6 @@ the same spider:
#!python
class MySpider(BaseSpider):
middlewares = [
RegexLinkExtractor(),
CallbackRules(),
@ -252,7 +251,6 @@ For example:
# Example spider using this middleware
class MySpider(BaseSpider):
middlewares = [RegexHtmlLinkExtractor()]
url_regexes_to_follow = ["/product.php?.*"]
@ -306,7 +304,6 @@ Another example could be to build a callback dispatcher based on rules:
# Example spider using this middleware
class MySpider(BaseSpider):
middlewares = [CallbackRules()]
callback_rules = {
"/product.php.*": "parse_product",
@ -333,7 +330,6 @@ Another example could be for building URL canonicalizers:
# Example spider using this middleware
class MySpider(BaseSpider):
middlewares = [CanonicalizeUrl()]
canonicalization_rules = ["sort-query-args", "normalize-percent-encoding", ...]
@ -358,7 +354,6 @@ certain fields:
# Example spider using this middleware
class MySpider(BaseSpider):
middlewares = [ItemIdSetter()]
id_field = "guid"
id_fields_to_hash = ["supplier_name", "supplier_id"]
@ -388,7 +383,6 @@ A spider middleware to avoid visiting pages forbidden by robots.txt:
class RobotsTxtMiddleware(object):
REQUEST_PRIORITY = 1000
def __init__(self):