Skip to content

πŸ•·οΈ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

13.3 KB
Raw Blame

title: "링크, μ‚¬μ΄νŠΈλ§΅, ν”Όλ“œ, Markdown용 μŠ€νŒŒμ΄λ” ν…œν”Œλ¦Ώ" description: "CrawlSpider, SitemapSpider, XMLFeedSpider, CSVFeedSpider, ContentSpider μ€‘μ—μ„œ μ„ νƒν•˜μ„Έμš”. νŽ˜μ΄μ§€, ν”Όλ“œ ν•­λͺ©, Markdown λ¬Έμ„œλ₯Ό μˆ˜μ§‘ν•  κ·œμΉ™μ„ μ„€μ •ν•©λ‹ˆλ‹€."

일반 μŠ€νŒŒμ΄λ” ν…œν”Œλ¦Ώ {#generic-spider-templates}

λŒ€λΆ€λΆ„μ˜ 크둀링은 νŠΉμ • νŒ¨ν„΄μ˜ 링크λ₯Ό λ”°λΌκ°€κ±°λ‚˜ μ‚¬μ΄νŠΈλ§΅μ— μžˆλŠ” λͺ¨λ“  URL을 λ°©λ¬Έν•©λ‹ˆλ‹€. Scrapling은 두 λ°©μ‹μ˜ ν…œν”Œλ¦Ώμ„ μ œκ³΅ν•˜λ―€λ‘œ 같은 parse() μ½”λ“œλ₯Ό 맀번 μž‘μ„±ν•  ν•„μš”κ°€ μ—†μŠ΅λ‹ˆλ‹€.

CrawlSpider와 SitemapSpiderλŠ” LinkExtractorλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€. 이 ν΄λž˜μŠ€λŠ” Responseμ—μ„œ URL을 μΆ”μΆœν•˜κ±°λ‚˜ matches()둜 URL ν•˜λ‚˜λ₯Ό κ²€μ‚¬ν•©λ‹ˆλ‹€. SitemapSpiderλŠ” gzip μ••μΆ• 여뢀와 관계없이 sitemap.xml / sitemap_index.xml 본문도 λ‚΄λΆ€μ—μ„œ νŒŒμ‹±ν•©λ‹ˆλ‹€.

일반 Spider.parse() μ•ˆμ—μ„œ LinkExtractorλ₯Ό 직접 μ‚¬μš©ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€. ν…œν”Œλ¦Ώμ€ 이 μ—°κ²° μž‘μ—…μ„ λŒ€μ‹ ν•΄ 쀄 λΏμž…λ‹ˆλ‹€.

CrawlSpider {#crawlspider}

CrawlSpiderλŠ” μ„ μ–Έν•œ κ·œμΉ™μ— 따라 링크λ₯Ό μžλ™μœΌλ‘œ λ”°λΌκ°‘λ‹ˆλ‹€.

from scrapling.spiders import CrawlSpider, CrawlRule, LinkExtractor

class QuotesSpider(CrawlSpider):
    name = "blog"
    start_urls = ["https://quotes.toscrape.com/"]

    def rules(self):
        return [
            CrawlRule(LinkExtractor(allow=r"/author/"), callback=self.parse_author),
            CrawlRule(LinkExtractor(allow=r"/page/\d+/")),  # follow pagination, no callback
        ]

    async def parse_author(self, response):
        yield {
            '.author-title': response.css('.author-title::text').get(),
            "birthday": response.css('.author-born-date::text').get(),
            "url": response.url,
        }

result = QuotesSpider().start()

CrawlRule은 LinkExtractor에 선택적 callback(μŠ€νŒŒμ΄λ”μ˜ λ°”μΈλ”©λœ λ©”μ„œλ“œ), 생성할 Request의 선택적 priority, 선택적 process_requestλ₯Ό μ—°κ²°ν•©λ‹ˆλ‹€. λ§ˆμ§€λ§‰ μΈμˆ˜λŠ” 각 Requestλ₯Ό 내보내기 전에 μˆ˜μ •ν•˜λŠ” λ°”μΈλ”©λœ λ©”μ„œλ“œμž…λ‹ˆλ‹€. κΈ°λ³Έ parse()λŠ” λͺ¨λ“  응닡에 λͺ¨λ“  κ·œμΉ™μ„ μ μš©ν•˜κ³ , μΌμΉ˜ν•˜λŠ” URLλ§ˆλ‹€ Requestλ₯Ό λ‚΄λ³΄λƒ…λ‹ˆλ‹€.

κ·œμΉ™μ— 콜백이 μ—†μœΌλ©΄ ν•΄λ‹Ή URL은 μŠ€νŒŒμ΄λ”μ˜ κΈ°λ³Έ parse()둜 μ „λ‹¬ν•©λ‹ˆλ‹€. λ‹€μŒ νŽ˜μ΄μ§€ 링크λ₯Ό μΆ”μΆœν•΄ 별도 콜백 없이 계속 λ°©λ¬Έν•  수 μžˆμœΌλ―€λ‘œ νŽ˜μ΄μ§€ λ‚˜λˆ„κΈ°μ— μœ μš©ν•©λ‹ˆλ‹€.

크둀링 μˆœμ„œ {#crawl-order}

CrawlSpiderλ‚˜ ContentSpiderλ₯Ό ν¬ν•¨ν•œ ν•˜μœ„ ν΄λž˜μŠ€μ—μ„œ crawl_strategyλ₯Ό μ„€μ •ν•΄ λŒ€κΈ° μš”μ²­μ˜ μˆœμ„œλ₯Ό μ„ νƒν•˜μ„Έμš”.

crawl_strategy 같은 Request.priority μ•ˆμ—μ„œμ˜ μˆœμ„œ
"bfs"(κΈ°λ³Έκ°’) 큐에 λ¨Όμ € λ“€μ–΄μ˜¨ μš”μ²­λΆ€ν„°
"dfs" 큐에 λ‚˜μ€‘μ— λ“€μ–΄μ˜¨ μš”μ²­λΆ€ν„°

μŠ€μΌ€μ€„λŸ¬λŠ” Request.priorityκ°€ 높은 λŒ€κΈ° μš”μ²­μ„ λ¨Όμ € μ„ νƒν•©λ‹ˆλ‹€. μ „λž΅μ€ μš°μ„ μˆœμœ„κ°€ 같은 μš”μ²­ μ‚¬μ΄μ˜ μˆœμ„œλ§Œ μ •ν•©λ‹ˆλ‹€.

μ„ νƒν•œ 큐 μˆœμ„œλŒ€λ‘œ μš”μ²­μ„ ν•˜λ‚˜μ”© μ²˜λ¦¬ν•˜λ €λ©΄ concurrent_requests = 1을 μ„€μ •ν•˜μ„Έμš”. 쀑볡 URL은 계속 μ œμ™Έν•˜λ©°, 같은 URL을 λ‹€μ‹œ λ°œκ²¬ν•΄λ„ 큐에 있던 μš”μ²­μ˜ μœ„μΉ˜λŠ” λ°”λ€Œμ§€ μ•ŠμŠ΅λ‹ˆλ‹€. λ™μ‹œ μš”μ²­μ„ μ‚¬μš©ν•˜λ©΄ νŽ˜μ΄μ§€κ°€ λλ‚˜λŠ” μˆœμ„œκ°€ 달라지고, 탐색 λ‹¨κ³„λ‚˜ λΆ„κΈ°κ°€ κ²ΉμΉ  수 μžˆμŠ΅λ‹ˆλ‹€.

μ²΄ν¬ν¬μΈνŠΈμ—μ„œ μž¬κ°œν•  λ•ŒλŠ” 같은 crawl_strategyλ₯Ό μœ μ§€ν•˜μ„Έμš”.

κ·œμΉ™μ— μ›ν•˜λŠ” λ™μž‘ λ”ν•˜κΈ° {#combining-rules-with-custom-logic}

parse()λ₯Ό μž¬μ •μ˜ν•˜κ³  super().parse(response)λ₯Ό ν˜ΈμΆœν•˜λ©΄ κ·œμΉ™μ— λ”°λ₯Έ λ™μž‘κ³Ό 직접 λ‚΄λ³΄λ‚΄λŠ” κ²°κ³Όλ₯Ό ν•¨κ»˜ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

class MySpider(CrawlSpider):
    def rules(self):
        return [CrawlRule(LinkExtractor(allow=r"/posts/"), callback=self.parse_post)]

    async def parse(self, response):
        yield {"page_url": response.url}
        async for req in super().parse(response):
            yield req

process_request둜 μš”μ²­ λ°”κΎΈκΈ° {#mutating-requests-with-process_request}

def add_priority(self, request, response):
    request.priority = 10
    return request

def rules(self):
    return [CrawlRule(
        LinkExtractor(allow=r"/posts/"),
        callback=self.parse_post,
        process_request=self.add_priority,
    )]

SitemapSpider {#sitemapspider}

SitemapSpiderλŠ” sitemap.xml의 URLμ—μ„œ 크둀링을 μ‹œμž‘ν•©λ‹ˆλ‹€. CrawlSpider와 같은 rules() APIλ₯Ό μ‚¬μš©ν•˜λ―€λ‘œ λ™μž‘ 방식을 ν•¨κ»˜ 이해할 수 μžˆμŠ΅λ‹ˆλ‹€.

from scrapling.spiders import SitemapSpider, CrawlRule, LinkExtractor

class MySitemap(SitemapSpider):
    name = "sm"
    sitemap_urls = ["https://example.com/sitemap.xml"]

    def rules(self):
        return [
            CrawlRule(LinkExtractor(allow=r"/posts/"), callback=self.parse_post),
            CrawlRule(LinkExtractor(allow=r"/products/"), callback=self.parse_product),
        ]

    async def parse_post(self, response):
        yield {"title": response.css("h1::text").get()}

    async def parse_product(self, response):
        yield {"sku": response.css(".sku::text").get()}

result = MySitemap().start()

URL을 콜백으둜 μ „λ‹¬ν•˜λŠ” 방식 {#how-urls-are-dispatched}

SitemapSpiderλŠ” μ‚¬μ΄νŠΈλ§΅μ˜ URLλ§ˆλ‹€ 각 κ·œμΉ™μ˜ LinkExtractor.matches(url)을 μˆœμ„œλŒ€λ‘œ ν™•μΈν•©λ‹ˆλ‹€. 처음 μΌμΉ˜ν•œ κ·œμΉ™μ„ μ„ νƒν•˜κ³ , κ·Έ μ½œλ°±μ„ κ°€μ§„ Requestλ₯Ό λ‚΄λ³΄λƒ…λ‹ˆλ‹€. rules()κ°€ λΉ„μ–΄ μžˆμ§€ μ•Šμ€λ° μΌμΉ˜ν•˜λŠ” κ·œμΉ™μ΄ μ—†μœΌλ©΄ URL을 μ œμ™Έν•©λ‹ˆλ‹€. rules()κ°€ 빈 리슀트이면 λͺ¨λ“  URL을 μŠ€νŒŒμ΄λ”μ˜ parse()둜 μ „λ‹¬ν•©λ‹ˆλ‹€. 이 λ©”μ„œλ“œλŠ” μž¬μ •μ˜ν•˜μ§€ μ•ŠμœΌλ©΄ 기본적으둜 NotImplementedErrorλ₯Ό λ°œμƒμ‹œν‚΅λ‹ˆλ‹€.

μ‚¬μ΄νŠΈλ§΅ 인덱슀 {#sitemap-indexes}

SitemapSpiderκ°€ μ‚¬μ΄νŠΈλ§΅ λͺ©λ‘μΈ <sitemapindex>λ₯Ό λ§Œλ‚˜λ©΄ ν•˜μœ„ μ‚¬μ΄νŠΈλ§΅μ„ μžλ™μœΌλ‘œ λ°©λ¬Έν•©λ‹ˆλ‹€. λ°©λ¬Έν•  ν•˜μœ„ μ‚¬μ΄νŠΈλ§΅μ„ μ œν•œν•˜λ €λ©΄ sitemap_follow에 LinkExtractorλ₯Ό μ„€μ •ν•˜μ„Έμš”.

class MySitemap(SitemapSpider):
    name = "sm"
    sitemap_urls = ["https://example.com/sitemap.xml"]
    sitemap_follow = LinkExtractor(allow=r"/posts-sitemap-\d+\.xml")  # only post sitemaps

robots.txt 지원 {#robotstxt-support}

robots.txt URL을 sitemap_urls에 λ°”λ‘œ λ„£μœΌλ©΄ SitemapSpiderκ°€ νŒŒμΌμ„ μ•Œμ•„λ³΄κ³ , λ‚˜μ—΄λœ λͺ¨λ“  μ‚¬μ΄νŠΈλ§΅μ„ μΆ”μΆœν•΄ λ°©λ¬Έν•©λ‹ˆλ‹€.

class MySitemap(SitemapSpider):
    name = "sm"
    sitemap_urls = ["https://example.com/robots.txt"]

λ‹€λ₯Έ μ–Έμ–΄μ˜ URL {#alternate-language-urls}

sitemap_alternate_links = Trueλ₯Ό μ„€μ •ν•˜λ©΄ <xhtml:link rel="alternate" hreflang="...">의 URL도 κ·œμΉ™μœΌλ‘œ μ²˜λ¦¬ν•©λ‹ˆλ‹€.

XMLFeedSpider {#xmlfeedspider}

XMLFeedSpiderλŠ” RSS, Atom, μƒν’ˆ ν”Όλ“œ λ“± XML ν”Όλ“œμ˜ λ…Έλ“œλ₯Ό μˆœνšŒν•©λ‹ˆλ‹€. itertag에 μ›ν•˜λŠ” λ…Έλ“œ 이름을 μ„€μ •ν•˜κ³ (κΈ°λ³Έκ°’: "item"), μΌμΉ˜ν•˜λŠ” λ…Έλ“œλ§ˆλ‹€ ν˜ΈμΆœν•  parse_node()λ₯Ό μž¬μ •μ˜ν•˜μ„Έμš”.

from scrapling.spiders import XMLFeedSpider

class RSSSpider(XMLFeedSpider):
    name = "rss"
    start_urls = ["https://example.com/feed.xml"]
    itertag = "item"

    async def parse_node(self, response, node):
        yield {
            "title": node.findtext("title"),
            "link": node.findtext("link"),
            "date": node.findtext("pubDate"),
        }

result = RSSSpider().start()

λ‹€λ₯Έ 콜백처럼 parse_node()도 Requestλ₯Ό 내보낼 수 μžˆμŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄ response.follow(node.findtext("link"), callback=self.parse_post)둜 ν”Όλ“œκ°€ κ°€λ¦¬ν‚€λŠ” νŽ˜μ΄μ§€λ₯Ό λ°©λ¬Έν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λ…Έλ“œ 선택과 νŒŒμ‹± {#how-nodes-are-matched-and-parsed}

parse_node()에 μ „λ‹¬ν•˜λŠ” λ…Έλ“œλŠ” λ„€μž„μŠ€νŽ˜μ΄μŠ€λ₯Ό λͺ¨λ‘ μ œκ±°ν•œ lxml μš”μ†Œμž…λ‹ˆλ‹€. λ”°λΌμ„œ node.findtext("title"), node.find("thumbnail").get("url"), λŒ€μ†Œλ¬Έμžλ₯Ό κ΅¬λΆ„ν•˜λŠ” node.xpath(...)λ₯Ό μ–΄λ–€ ν”Όλ“œμ—μ„œλ“  λ„€μž„μŠ€νŽ˜μ΄μŠ€ λ§€ν•‘ 없이 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. "entry"처럼 λ‹¨μˆœν•œ itertagλŠ” λ„€μž„μŠ€νŽ˜μ΄μŠ€μ™€ 관계없이 μ΄λ¦„μœΌλ‘œ λ…Έλ“œλ₯Ό μ°ΎμŠ΅λ‹ˆλ‹€. Atomκ³Ό λŒ€λΆ€λΆ„μ˜ λ„€μž„μŠ€νŽ˜μ΄μŠ€κ°€ μžˆλŠ” ν”Όλ“œμ— μ ν•©ν•©λ‹ˆλ‹€. νŠΉμ • λ„€μž„μŠ€νŽ˜μ΄μŠ€μ˜ λ…Έλ“œλ§Œ 찾으렀면 접두사가 μžˆλŠ” itertagλ₯Ό μ‚¬μš©ν•˜κ³  namespaces에 접두사λ₯Ό μ •μ˜ν•˜μ„Έμš”.

class ThumbnailSpider(XMLFeedSpider):
    name = "thumbs"
    start_urls = ["https://example.com/feed.xml"]
    itertag = "media:thumbnail"
    namespaces = (("media", "http://search.yahoo.com/mrss/"),)

    async def parse_node(self, response, node):
        yield {"thumbnail": node.get("url")}

gzip ν”Όλ“œ(.xml.gz λ˜λŠ” gzip μ½˜ν…μΈ  νƒ€μž…μœΌλ‘œ μ œκ³΅λ˜λŠ” ν”Όλ“œ)λŠ” μ‚¬μ΄νŠΈλ§΅ μŠ€νŒŒμ΄λ”μ™€ 같은 보호 κΈ°λŠ₯으둜 μžλ™ μ••μΆ• ν•΄μ œν•©λ‹ˆλ‹€. 잘λͺ»λœ XML은 크둀링을 μ€‘λ‹¨ν•˜μ§€ μ•Šκ³  κ²½κ³ λ₯Ό κΈ°λ‘ν•©λ‹ˆλ‹€.

CSVFeedSpider {#csvfeedspider}

CSVFeedSpiderλŠ” CSV ν”Όλ“œμ˜ 행을 μˆœνšŒν•©λ‹ˆλ‹€. μ—΄ 이름을 ν‚€λ‘œ ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬λ‘œ 각 행을 λ°›λŠ” parse_row()λ₯Ό μž¬μ •μ˜ν•˜μ„Έμš”.

from scrapling.spiders import CSVFeedSpider

class PriceSpider(CSVFeedSpider):
    name = "prices"
    start_urls = ["https://example.com/products.csv"]

    async def parse_row(self, response, row):
        yield {"product": row["title"], "price": float(row["price"])}

result = PriceSpider().start()

기본적으둜 첫 행을 ν—€λ”λ‘œ μ‚¬μš©ν•©λ‹ˆλ‹€. 헀더 행이 μ—†μœΌλ©΄ headers에 μ—΄ 이름을 직접 μ§€μ •ν•˜μ„Έμš”. ν‘œμ€€ μ‰Όν‘œ ν˜•μ‹μ΄ μ•„λ‹ˆλΌλ©΄ delimiter/quotecharλ₯Ό μ„€μ •ν•˜μ„Έμš”.

class PriceSpider(CSVFeedSpider):
    name = "prices"
    start_urls = ["https://example.com/products.csv"]
    headers = ["title", "price", "url"]
    delimiter = ";"

μœ„μ˜ XMLFeedSpider처럼 gzip ν”Όλ“œλ„ μžλ™μœΌλ‘œ μ••μΆ• ν•΄μ œν•©λ‹ˆλ‹€.

ContentSpider {#contentspider}

ContentSpiderλŠ” CrawlSpiderλ₯Ό λ°”νƒ•μœΌλ‘œ μ‚¬μ΄νŠΈλ₯Ό λ°©λ¬Έν•˜κ³  각 νŽ˜μ΄μ§€λ₯Ό LLM에 μ „λ‹¬ν•˜κΈ° 쒋은 μ •λ¦¬λœ Markdown으둜 λ°”κΏ‰λ‹ˆλ‹€. νŽ˜μ΄μ§€λ§ˆλ‹€ ν•­λͺ© ν•˜λ‚˜λ₯Ό 내보내며, ν•„μš”ν•˜λ©΄ Markdown νŒŒμΌλ„ ν•˜λ‚˜μ”© μž‘μ„±ν•©λ‹ˆλ‹€.

from scrapling.spiders import ContentSpider

class DocsSpider(ContentSpider):
    name = "docs"
    start_urls = ["https://example.com/docs/"]
    allowed_domains = {"example.com"}
    output_dir = "docs_markdown"

result = DocsSpider().start()

크둀링 λ²”μœ„λ₯Ό λŒ€μƒ μ‚¬μ΄νŠΈλ‘œ μ œν•œν•˜λ„λ‘ allowed_domainsλ₯Ό μ„€μ •ν•΄μ•Ό ν•©λ‹ˆλ‹€. 전체 μ˜΅μ…˜κ³Ό RAG νŒŒμ΄ν”„λΌμΈμ— κ²°κ³Όλ₯Ό μ „λ‹¬ν•˜λŠ” 방법은 RAG μ‹œμŠ€ν…œ λ§Œλ“€κΈ°λ₯Ό μ°Έκ³ ν•˜μ„Έμš”.

LinkExtractor 직접 μ‚¬μš©ν•˜κΈ° {#using-linkextractor-directly}

ν…œν”Œλ¦Ώμ€ ν•„μˆ˜κ°€ μ•„λ‹™λ‹ˆλ‹€. LinkExtractorλŠ” 일반 Spider μ•ˆμ—μ„œλ„ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

from scrapling.spiders import Spider, LinkExtractor

class CustomSpider(Spider):
    name = "custom"
    start_urls = ["https://example.com"]

    def __init__(self):
        super().__init__()
        self._links = LinkExtractor(allow=r"/posts/", deny_domains="ads.example.com")

    async def parse(self, response):
        for url in self._links.extract(response):
            yield response.follow(url, callback=self.parse_post)

    async def parse_post(self, response):
        yield {"title": response.css("h1::text").get()}

LinkExtractor 참고 자료 {#linkextractor-reference}

인수 κΈ°λ³Έκ°’ μ„€λͺ…
allow () μœ μ§€ν•  URL νŒ¨ν„΄μž…λ‹ˆλ‹€. λΉ„μ–΄ 있으면 λͺ¨λ‘ ν—ˆμš©ν•©λ‹ˆλ‹€. λ¬Έμžμ—΄, μ»΄νŒŒμΌν•œ Pattern, λ˜λŠ” 이 값을 담은 반볡 κ°€λŠ₯ν•œ 객체λ₯Ό λ°›μŠ΅λ‹ˆλ‹€
deny () μ œμ™Έν•  URL νŒ¨ν„΄μž…λ‹ˆλ‹€. 항상 allow보닀 μš°μ„ ν•©λ‹ˆλ‹€
allow_domains () ν—ˆμš©ν•  호슀트 μ΄λ¦„μž…λ‹ˆλ‹€. ν•˜μœ„ 도메인도 ν—ˆμš©ν•˜λ―€λ‘œ example.com은 api.example.com과도 μΌμΉ˜ν•©λ‹ˆλ‹€
deny_domains () μ œμ™Έν•  호슀트 이름
restrict_css () DOMμ—μ„œ 링크λ₯Ό μΆ”μΆœν•  μ˜μ—­μ„ μ œν•œν•˜λŠ” CSS μ„ νƒμž
restrict_xpath () DOMμ—μ„œ 링크λ₯Ό μΆ”μΆœν•  μ˜μ—­μ„ μ œν•œν•˜λŠ” XPath μ„ νƒμž
tags ("a", "area") 링크λ₯Ό 찾을 μš”μ†Œ νƒœκ·Έ
attrs ("href",) ν•΄λ‹Ή νƒœκ·Έμ—μ„œ URL을 읽을 속성
canonicalize True 쿼리 인수λ₯Ό μ •λ ¬ν•˜κ³  경둜λ₯Ό μ •κ·œν™”ν•©λ‹ˆλ‹€
strip True μΆ”μΆœν•œ URL μ–‘ 끝의 곡백을 μ œκ±°ν•©λ‹ˆλ‹€
keep_fragment False μ •κ·œν™”ν•  λ•Œ #fragmentλ₯Ό μœ μ§€ν•©λ‹ˆλ‹€
deny_extensions IGNORED_EXTENSIONS μ œμ™Έν•  파일 ν™•μž₯μžμž…λ‹ˆλ‹€. pdf, zip, 이미지, λ™μ˜μƒ 등이 ν•΄λ‹Ήν•©λ‹ˆλ‹€
process None 필터링 전에 μΆ”μΆœν•œ URLλ§ˆλ‹€ μ μš©ν•  선택적 호좜 κ°€λŠ₯ κ°μ²΄μž…λ‹ˆλ‹€. κ±°μ§“μœΌλ‘œ ν‰κ°€λ˜λŠ” 값을 λ°˜ν™˜ν•˜λ©΄ URL을 μ œμ™Έν•©λ‹ˆλ‹€

LinkExtractor.extract(response)λŠ” 필터링과 쀑볡 제거λ₯Ό 마친 μ ˆλŒ€ URL의 list[str]λ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.

LinkExtractor.matches(url)은 bool을 λ°˜ν™˜ν•˜λŠ” URL μ „μš© ν•„ν„°μž…λ‹ˆλ‹€. ν—ˆμš©/μ œμ™Έ νŒ¨ν„΄, 도메인, ν™•μž₯자λ₯Ό κ²€μ‚¬ν•©λ‹ˆλ‹€. SitemapSpiderλŠ” 이 λ©”μ„œλ“œλ‘œ Response 없이 URL을 전달할 κ·œμΉ™μ„ μ •ν•©λ‹ˆλ‹€.