-
Notifications
You must be signed in to change notification settings - Fork 0
/
n_ofbl
executable file
·63 lines (48 loc) · 1.37 KB
/
n_ofbl
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
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''Copyright (c) 2016, Ryo Hanafusa.
All rights reserved.'''
import os
import sys
try:
MY_MODUDLES = [
'urldl-2.3-n',
'colpri-2.3',
'fileope-1.0'
]
for mod in MY_MODUDLES:
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/' + mod)
from fileope import FileOperation
from urldl_n import NURLDownload
from colpri import ColorPrint
from n_scrape_urllib import NScrape
except:
print 'Could not load some modules'
sys.exit(1)
finally:
pass
def main():
'''main'''
ns = NScrape()
c_p = ColorPrint()
n_dler = NURLDownload()
stg = FileOperation()
print c_p.with_color('N Official Blog Scraping', 'purple')
print c_p.with_color('Checking the savepath', 'cyan')
n_dler.load_savepath()
print c_p.with_color('Checking the latest image URL', 'cyan')
stg.load_file('LATEST_IMAGE_URL.txt')
latest_image_url = stg.readline()
ns.set_latest_image_url(latest_image_url)
ns.set_dler(n_dler)
ns.scrape('http://hoge.n.com')
print '\n*** Scaping finish ***'
new_latest_image_url = ns.get_new_latest_image_url()
stg.update_content(new_latest_image_url)
print c_p.with_color(
['Downloaded',
str(ns.image_number),
'images'],
'purple')
if __name__ == '__main__':
main()