mirror of https://github.com/scrapy/scrapy.git
Added normalize_urls adaptor, which was mentioned in the previous changeset, but not actually commited
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40349
This commit is contained in:
parent
377bea4976
commit
c73dc5ad6c
|
|
@ -1,5 +1,6 @@
|
|||
import re
|
||||
from scrapy.xpath.selector import XPathSelector, XPathSelectorList
|
||||
from scrapy.utils.url import canonicalize_url
|
||||
from scrapy.utils.misc import extract_regex
|
||||
from scrapy.utils.python import flatten
|
||||
|
||||
|
|
@ -26,6 +27,13 @@ def strip_list(value):
|
|||
def drop_empty(value):
|
||||
return [ v for v in value if v ]
|
||||
|
||||
def normalize_urls(value):
|
||||
if hasattr(value, '__iter__'):
|
||||
return [canonicalize_url(url) for url in value]
|
||||
elif isinstance(value, basestring):
|
||||
return canonicalize_url(value)
|
||||
return ''
|
||||
|
||||
class Delist(object):
|
||||
"""
|
||||
Input: iterable with strings
|
||||
|
|
|
|||
Loading…
Reference in New Issue