i have list of relatives urls, , need complete url. i'm using scrapy.
i can 1 url with
urljoin(response.url,url_list[0]) but want apply function whole list, i've tried this:
map(urljoin,response.url,url_list) but doesn't work
i'd go list comprehension - more readable , faster:
[urljoin(response.url, url) url in url_list] but if still want map(), need use functools.partial():
from functools import partial map(partial(urljoin, response.url), url_list) demo:
>>> urlparse import urljoin >>> functools import partial >>> >>> >>> url_list = ["1", "2", "3"] >>> map(partial(urljoin, "https://google.com"), url_list) ['https://google.com/1', 'https://google.com/2', 'https://google.com/3']
Comments
Post a Comment