diff --git a/recipes/gosc_full.recipe b/recipes/gosc_full.recipe index 5903e809e1..07c36141eb 100644 --- a/recipes/gosc_full.recipe +++ b/recipes/gosc_full.recipe @@ -24,20 +24,27 @@ class GN(BasicNewsRecipe): doc = html.fromstring(raw) page = doc.xpath('//div[@class="c"]//div[@class="search-result"]/div[1]/div[2]/h1//a/@href') - return page[4] + if time.strftime("%w") in ['3','4']: + return page[5] + else: + return page[4] def parse_index(self): soup = self.index_to_soup('http://gosc.pl' + self.find_last_issue()) self.cover_url = 'http://www.gosc.pl' + soup.find('div',attrs={'class':'fl-w100 release-wp'}).findAll('a')[-4].contents[0]['src'] feeds = [] - # wstepniak - a = soup.find('div',attrs={'class':'release-wp-b'}).find('a') + enlisted = [] + # editorial: + a = soup.find('div',attrs={'class':'release-wp-b'}) + art = a.find('a') articles = [ - {'title' : self.tag_to_string(a), - 'url' : 'http://www.gosc.pl' + a['href'] + {'title' : self.tag_to_string(art), + 'url' : 'http://www.gosc.pl' + art['href'], + 'description' : self.tag_to_string(a.find('p',attrs={'class':'b lead'})) }] feeds.append((u'Wstępniak',articles)) - # kategorie + enlisted.append(articles[0].get('url')) + # columns: for addr in soup.findAll('a',attrs={'href':re.compile('kategoria')}): if addr.string != u'wszystkie artyku\u0142y z tej kategorii \xbb': main_block = self.index_to_soup('http://www.gosc.pl' + addr['href']) @@ -45,6 +52,20 @@ class GN(BasicNewsRecipe): if len(articles) > 0: section = addr.string feeds.append((section, articles)) + enlisted.extend(list(article.get('url') for article in articles)) + # not assigned content: + page = 1 + not_assigned = [] + while True: + soup = self.index_to_soup('http://gosc.pl' + self.find_last_issue().replace('przeglad','wszystko') + '/' + str(page)) + articles = list(self.find_articles(soup)) + not_assigned.extend([ x for x in articles if x.get('url') not in enlisted ]) + page+=1 + pages = soup.find('span', attrs={'class':'pgr_nrs'}) + if str(page) not in [self.tag_to_string(x)[1] for x in pages.findAll('a')]: + break + + feeds.insert(1,(u'Nieprzypisane', not_assigned)) return feeds def find_articles(self, main_block): @@ -52,7 +73,9 @@ class GN(BasicNewsRecipe): art = a.find('a') yield { 'title' : self.tag_to_string(art), - 'url' : 'http://www.gosc.pl' + art['href'] + 'url' : 'http://www.gosc.pl' + art['href'], + 'date' : self.tag_to_string(a.find('p', attrs={'class':'sr-date'})), + 'description' : self.tag_to_string(a.find('p', attrs={'class':'sr-lead'})) } def append_page(self, soup, appendtag): @@ -77,7 +100,7 @@ class GN(BasicNewsRecipe): for r in soup.findAll(attrs={'class':['di_dr', 'doc_image']}): del r['style'] for r in soup.findAll(attrs={'class':'cm-i-a'}): - r.replaceWith( r.prettify() + '
') + r.replaceWith( '' + r.prettify() + '') return soup keep_only_tags = [ @@ -88,6 +111,7 @@ class GN(BasicNewsRecipe): dict(name='p', attrs={'class':['r tr', 'l l-2', 'wykop', 'tags']}), dict(name='div', attrs={'class':['doc_actions', 'cf', 'fr1_cl']}), dict(name='div', attrs={'id':'vote'}), + dict(name='link'), dict(name='a', attrs={'class':'img_enlarge'}) ]