-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
18 lines (17 loc) · 746 Bytes
/
Copy pathmain.py
File metadata and controls
18 lines (17 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from args import get_args
from crawler import Crawler
from datetime import datetime
if __name__ == '__main__':
args = get_args()
crawler = Crawler()
contents = crawler.crawl(args.start_date, args.end_date)
# TODO: write content to file according to spec
f = open(args.output+'.csv','w')
f.write('Post date,Title,Content\n')
for date,title,content in contents:
if args.start_date > datetime.strptime(date,"%Y-%m-%d") or datetime.strptime(date,"%Y-%m-%d") > args.end_date:
continue
f.write('"'+date.replace('"','""')+'",')
f.write('"'+title.replace('"','""')+'",')
f.write('"'+''.join(content).replace('\r','').replace('\xa0','\n').replace('"','""')+'"\n')
f.close()