This commit is contained in:
Kovid Goyal 2011-10-13 09:00:04 +05:30
parent dff33cf99b
commit e802938b5e

View File

@ -10,17 +10,17 @@ import re
class GN(BasicNewsRecipe): class GN(BasicNewsRecipe):
EDITION = 0 EDITION = 0
__author__ = 'Piotr Kontek' __author__ = 'Piotr Kontek'
title = unicode('Gość niedzielny') title = u'Gość niedzielny'
description = 'Weekly magazine' description = 'Weekly magazine'
encoding = 'utf-8' encoding = 'utf-8'
no_stylesheets = True no_stylesheets = True
language = 'pl' language = 'pl'
remove_javascript = True remove_javascript = True
temp_files = [] temp_files = []
simultaneous_downloads = 1 simultaneous_downloads = 1
articles_are_obfuscated = True articles_are_obfuscated = True
def get_obfuscated_article(self, url): def get_obfuscated_article(self, url):
@ -28,9 +28,9 @@ class GN(BasicNewsRecipe):
br.open(url) br.open(url)
source = br.response().read() source = br.response().read()
page = self.index_to_soup(source) page = self.index_to_soup(source)
main_section = page.find('div',attrs={'class':'txt doc_prnt_prv'}) main_section = page.find('div',attrs={'class':'txt doc_prnt_prv'})
title = main_section.find('h2') title = main_section.find('h2')
info = main_section.find('div', attrs={'class' : 'cf doc_info'}) info = main_section.find('div', attrs={'class' : 'cf doc_info'})
authors = info.find(attrs={'class':'l'}) authors = info.find(attrs={'class':'l'})
@ -42,17 +42,17 @@ class GN(BasicNewsRecipe):
article = article + str(p.find('img')).replace('src="/files/','src="http://www.gosc.pl/files/') article = article + str(p.find('img')).replace('src="/files/','src="http://www.gosc.pl/files/')
article = article + '<font size="-2">' article = article + '<font size="-2">'
for s in p.findAll('span'): for s in p.findAll('span'):
article = article + self.tag_to_string(s) article = article + self.tag_to_string(s)
article = article + '</font></p>' article = article + '</font></p>'
else: else:
article = article + str(p).replace('src="/files/','src="http://www.gosc.pl/files/') article = article + str(p).replace('src="/files/','src="http://www.gosc.pl/files/')
first = False first = False
html = unicode(title) + unicode(authors) + unicode(article) html = unicode(title) + unicode(authors) + unicode(article)
self.temp_files.append(PersistentTemporaryFile('_temparse.html')) self.temp_files.append(PersistentTemporaryFile('_temparse.html'))
self.temp_files[-1].write(html) self.temp_files[-1].write(html)
self.temp_files[-1].close() self.temp_files[-1].close()
return self.temp_files[-1].name return self.temp_files[-1].name
def find_last_issue(self): def find_last_issue(self):
@ -69,7 +69,7 @@ class GN(BasicNewsRecipe):
if not first: if not first:
break break
first = False first = False
def parse_index(self): def parse_index(self):
self.find_last_issue() self.find_last_issue()
soup = self.index_to_soup('http://www.gosc.pl' + self.EDITION) soup = self.index_to_soup('http://www.gosc.pl' + self.EDITION)