Spaces:
Runtime error
Runtime error
File size: 549 Bytes
21e639d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from typing import List
from scrapy.selector import Selector
from scrapy.http.response.html import HtmlResponse
def get_title_tags(response: HtmlResponse) -> List[Selector]:
"""The get_title_tags function gets the title tags DOM.
Args:
response (HtmlResponse): the scrapy HtmlResponse.
Returns:
a list of scrapy anchor tag selectors
"""
title_css = ".r-ent .title a"
if response.url.endswith("index.html"):
return response.dom(".r-list-sep").prev_all(title_css)
return response.dom(title_css)
|