def check_new(option): if not os.path.isfile(helper.TEMP_DIR + '/yinBlog_1stURL.txt'): firstURL_persistence() helper.logger_getter().info( "First init to store the url of the first post!") exit(0) with open(helper.TEMP_DIR + '/yinBlog_1stURL.txt') as f: # if new first url doesn't equal to the record one, upgrade it first! if first_aTag.get('href') != f.readline(): helper.logger_getter().info('Yinwang published a new blog!') helper.logger_getter().info('Renew the first url in the file') firstURL_persistence() blog_url = 'http://www.yinwang.org' + first_aTag.get('href') blog_title = first_aTag.get_text().strip() helper.mail_send('垠神发表了新Blog: ' + blog_title, blog_url) # begin making screenshot helper.dir_check('yinBlogBak') html.make_screenshot( blog_url, helper.CURR_PATH + '/yinBlogBak/' + blog_title + '.png') # decide whether push the screenshot to github repo or not if option: os.system('git add .') os.system("git commit -m 'backup yinwang blog'") os.system('git push origin master') else: helper.logger_getter.info('Yin did not publish any blog yet!')
def id_persistence(): helper.dir_check(helper.TEMP_DIR) with open(helper.TEMP_DIR + '/v2ex_id_data.txt', 'w') as f: for _ in html.page_source_get(hot_url): f.write(str(_['id']) + '\n')
def data_persistence(self, obj_id): helper.dir_check() temp_data = 'tmp/obj_id' with open(temp_data, 'w') as f: f.write(obj_id)
def firstURL_persistence(): helper.dir_check(helper.TEMP_DIR) with open(helper.TEMP_DIR + '/yinBlog_1stURL.txt', 'w') as f: f.write(first_aTag.get('href'))