def get_info_once(count, time_now): # 基础页面的解析 base_info_url_dealer = URLDealer(Setting.base_url, Setting.timeout) base_info_soup = base_info_url_dealer.get_soup() plague_info = PlagueInfo(base_info_soup) # 获取全国信息,分省信息,图片url detailed_info = plague_info.detailed_info() total_info = plague_info.total_info(detailed_info) # img_url = plague_info.img_url() # 全国信息,分省信息的存储 mySQL = MySQLSaver(Setting.db) save_total_info(mySQL, total_info) save_detailed_info(mySQL, detailed_info, count) mySQL.close()
def main(): while True: # 基础页面的解析 base_info_url_dealer = URLDealer(Setting.base_url, Setting.timeout) base_info_soup = base_info_url_dealer.get_soup() plague_info = PlagueInfo(base_info_soup) mysql_saver = MySQLSaver(plague_info) mysql_saver.save_info_once() time.sleep(Setting.loop_time)
def test_total_info(): soup = URLDealer(Setting.base_url, Setting.timeout).get_soup() plague_info = PlagueInfo(soup) detailed_info = plague_info.detailed_info() return plague_info.total_info(detailed_info)
def test_china_info(): text = URLDealer(Setting.base_url, Setting.timeout).get_response_text() plague_info = PlagueInfo(text) return plague_info.china_info()
def test_world_info(): soup = URLDealer(Setting.base_url, Setting.timeout).get_soup() plague_info = PlagueInfo(soup) return plague_info.world_info()