def parse(self, response): all_channels = response.xpath('//div[@class="zip__network"]') base_price = response.xpath( 'substring-after(substring-before(//span[@class="price"]/text(), "/"), "$")' ).extract()[0].strip() for channel in all_channels: name = channel.xpath( './p[@class="zip__network-name"]/text()').extract()[0].strip() package = {'service': YoutubetvSpider.service} channel_page = channel.xpath('./a[1]/@href').extract() if not channel_page: if channel.xpath( './ancestor::ul[@class="zip__networks"]/preceding-sibling::h4[contains(., "Additional Networks")]' ): package['name'] = 'Add-On' else: package['name'] = 'Base' package['price'] = base_price yield ChannelItem(name=name, package=package) else: yield Request(channel_page[0], callback=self.parse_base_channels, meta={ 'name': name, 'base_price': base_price, 'package': package })
def parse_base_channels(self, response): jsonresponse = json.loads(response.body_as_unicode()) for market in jsonresponse['markets']: for channel in market['channels']: if not channel['add_on']: package = {'service': YoutubetvSpider.service, 'price': response.meta['price'], 'name': 'Base'} yield ChannelItem(name=channel['display_name'], package=package)
def parse(self, response): jsonresponse = json.loads(response.body_as_unicode()) for package_obj in jsonresponse['subscriptions']: package = { 'service': PsvueSpider.service, 'name': package_obj['entitlementName'], 'price': package_obj['regularPrice'] } for channel in package_obj['channels']: yield ChannelItem(name=channel['name'], package=package)
def parse(self, response): network_list = response.xpath( '//div[@id="channels"]/following-sibling::div//div[@class="network-list"]/img' ) package = {'service': HuluSpider.service, 'name': 'Base'} package['price'] = response.xpath( '//div[contains(@class, "plan-card__priceline")]//text()[contains(., ".")]' ).extract()[0].strip() for channel in network_list: name = channel.xpath('./@alt').extract()[0] yield ChannelItem(name=name, package=package)
def parse(self, response): premium_row = response.xpath('//ul[contains(@class, "network-matrix__cells--premium")]/li') for premium_element in premium_row: package = {'service': YoutubetvSpider.service, 'name': 'Add-On'} package['price'] = premium_element.xpath('substring-after(./div[@class="caption"]/text(), "$")').extract()[0].replace("/mo", "").strip() name = premium_element.xpath('./div[contains(@class, "network-matrix__cells-cell-cloak")]/@aria-label').extract()[0].strip() yield ChannelItem(name=name, package=package) base_price = response.xpath('substring-after(substring-before(//p[@class="c-hero-banner__content-price"]/text(), "/"), "$")').extract()[0].strip() yield Request('https://youtube-tv-zip-lookup.appspot.com/zipLookup/v1/availability/33065', callback=self.parse_base_channels, meta={'price': base_price})
def parse(self, response): package = {'name': 'Base', 'service': PhiloSpider.service} channel_container = response.xpath('//div[@class="channels"]') package['price'] = channel_container.xpath( 'substring-before(substring-after(./h5[@class="channels-head"]/text(), "$"), "/")' ).extract()[0] channel_elements = channel_container.xpath( './div[@class="channels-list"]/div[@class="channel-logo"]') for channel_element in channel_elements: name = channel_element.xpath('./img/@title').extract()[0] yield ChannelItem(name=name, package=package)
def get_channels(self, response, packages): channel_elements = response.xpath('//div[contains(@class, "channel")]') channels = [] for channel_element in channel_elements: title = self.get_channel_title(channel_element) for idx, availability in enumerate( channel_element.xpath( './/div[contains(@class, "col-custom")]')): if availability.xpath('./span[@class="checked"]'): channels.append( ChannelItem(name=title, package=packages[idx])) return channels
def parse_package(self, response): jsonresponse = json.loads(response.body_as_unicode()) matched_package = self.regex_package.search(response.url) if not matched_package: return package_id = matched_package.groups()[0] package_name = SlingSpider.translated_package_names[package_id] package = {'service': SlingSpider.service, 'name': package_name} package['price'] = response.meta['package_prices'][ self.translated_package_names[package_id]] for channel in jsonresponse: yield ChannelItem(name=channel['altText'], package=package)
def parse_base_channels(self, response): package = response.meta['package'] price = response.xpath( 'substring-after(substring-before(//div[@class="ytv-promo-drawer-text-primary"]/text(), "/"), "$")' ).extract() if not price: price = response.meta['base_price'] else: price = price[0].strip() package['price'] = price if response.xpath( '//div[@class="ytv-promo-drawer-additional-description"][contains(., "additional fee")]' ): package['name'] = 'Add-On' else: package['name'] = 'Base' yield ChannelItem(name=response.meta['name'], package=package)