def parse_directory(self, response): hxs = Selector(response) for li in hxs.xpath('//ul[@class="directory-url"]/li'): el = ExampleLoader(selector=li) el.add_xpath('name', 'a/text()') el.add_xpath('description', 'text()') el.add_xpath('link', 'a/@href') el.add_value('url', response.url) yield el.load_item()
def parse_directory(self, response): hxs = Selector(response) for li in hxs.xpath('//ul[@class="directory-url"]/li'): el = ExampleLoader(selector=li) el.add_xpath("name", "a/text()") el.add_xpath("description", "text()") el.add_xpath("link", "a/@href") el.add_value("url", response.url) yield el.load_item()
def parse_directory(self, response): for li in response.css('ul.directory-url > li'): el = ExampleLoader(selector=li) el.add_css('name', 'a::text') el.add_css('description', '::text') el.add_css('link', 'a::attr(href)') el.add_value('url', response.url) yield el.load_item()
def parse_directory(self, response): for li in response.css("ul.directory-url > li"): el = ExampleLoader(selector=li) el.add_css("name", "a::text") el.add_css("description", "::text") el.add_css("link", "a::attr(href)") el.add_value("url", response.url) yield el.load_item()
def parse_page(self, response): if 'tieba' not in response.url: return el = ExampleLoader(response=response) el.add_xpath('name', '//title[1]/text()') el.add_value('url', response.url) return el.load_item()
def parse_page(self, response): el = ExampleLoader(response=response) el.add_xpath('name', '//title[1]/text()') el.add_value('url', response.url) return el.load_item()
def parse_directory(self, response): hxs = HtmlXPathSelector(response) for li in hxs.select('//ul[@class="directory-url"]/li'): el = ExampleLoader(selector=li) el.add_xpath('name', 'a/text()') el.add_xpath('description', 'text()') el.add_xpath('link', 'a/@href') el.add_value('url', response.url) yield el.load_item()