-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
53 lines (35 loc) · 1.32 KB
/
test.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
import re
import time
from datetime import date
# get post list - mobile
def getMobileWeeklyList():
res = requests.get('http://bunker1church.com/')
soup = BeautifulSoup(res.text)
regex = re.compile(ur'([0-9]{1,2})[월/]?[ \t]*([0-9]{1,2})일?[ \t]?(.*)$');
weeklies = [];
cur_year = int(date.today().year)
if date.today().month == 12:
cur_year = cur_year + 1
for sermon in soup.find_all(class_='under-slider-sermon-wrapper') + soup.find_all(class_='sermon-content-wrapper'):
title = sermon.find(class_='sermon-title').find('span')
if not title:
title = sermon.find(class_='sermon-title')
group = regex.match(title.text).groups();
title = group[2]
cur_month = int(group[0])
cur_day = int(group[1])
if cur_month == 12:
cur_year = cur_year - 1
weekly = {
"title":title,
"date":date(cur_year, cur_month, cur_day),
"speaker":re.search(u":[ \t]*(.*)",unicode(sermon.find(class_='sermon-author').text)).group(1),
"link":sermon.find(class_='sermon-pdf').find('a')['href']
}
weeklies.append(weekly)
return weeklies
for w in getMobileWeeklyList():
print w['author']