0%

Android官方培训课程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from calibre.web.feeds.recipes import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import NavigableString, Tag

class DesignPattern(BasicNewsRecipe):

title = 'Android官方培训课程'
description = 'Android官方培训课程'
cover_url = 'http://hukai.me/android-training-course-in-chinese/android_training.jpg'

url_prefix = 'http://hukai.me/android-training-course-in-chinese/'
url = 'http://hukai.me/android-training-course-in-chinese/'
no_stylesheets = True
keep_only_tags = [dict(attrs={'class' : ['page-inner']})]

def get_text(self, tag):
text = ''
for c in tag.contents:
if isinstance(c, NavigableString):
text = text + str(c)
else:
text = text + self.get_text(c)

return text.strip()

def parse_index(self):
soup = self.index_to_soup(self.url)

div = soup.find('ul', { 'class': 'summary' })

articles = []
for link in div.findAll('a'):
til = self.get_text(link)
url = self.url_prefix +'/'+ link['href']
a = { 'title': til, 'url': url }

articles.append(a)

ans = [('Android官方培训课程', articles)]

return ans
Read more »