示例#1
0
def parse_href_end_num(obj_name: str, logger: Logger,
                       selector: SelectorList) -> int:
    logger.info('--------------------------parse_href_end_num()')
    url: str = validate(
        f'url of {obj_name}', logger,
        selector.xpath('@href').get())  # e.g. 'https://hoge.com/huga/114514/'
    return int(
        validate(f'{obj_name} in url', logger, safe_get(url.split('/'), -2)))
示例#2
0
 def parse(self, response):
     menu = response.css('#top-menu').xpath('ul/li/ul')
     lis = menu.xpath('li').extract()
     if self.categories:
         lis = SelectorList([li for cat in self.categories
                             for li in menu.xpath('li[h3[contains(text(), "' + cat + '")]]')
                             if cat])
     for url in lis.xpath('ul/li/a[not(contains(text(), "All"))]/@href').extract():
         yield Request(url, callback=self.parse_items)
示例#3
0
 def parse(self, response):
     menu = response.css('#nav_custom').xpath('li/ul')
     lis = menu.xpath('li')
     if self.categories:
         lis = SelectorList([li for cat in self.categories
                             for li in menu.xpath('li[a[span[text() = "' + cat + '"]]]')
                             if cat])
     for url in lis.xpath('ul/li/a[span[not(contains(text(), "Accessories"))]]/@href').extract():
         yield Request("%s?limit=all" % url, callback=self.parse_items)
示例#4
0
 def parse(self, response):
     menu = get_extracted(response.css('#vmenu_69'))
     lis = menu.xpath('li')
     if self.categories:
         lis = SelectorList([li for cat in self.categories
                             for li in menu.xpath('li[div/a[text() = "' + cat + '"]]')
                             if cat])
     for url in lis.xpath('div/a/@href').extract():
         yield Request(url, callback=self.parse_items)
示例#5
0
 def parse(self, response):
     menu = response.css('#top-menu').xpath('ul/li/ul')
     lis = menu.xpath('li').extract()
     if self.categories:
         lis = SelectorList([
             li for cat in self.categories
             for li in menu.xpath('li[h3[contains(text(), "' + cat + '")]]')
             if cat
         ])
     for url in lis.xpath(
             'ul/li/a[not(contains(text(), "All"))]/@href').extract():
         yield Request(url, callback=self.parse_items)