def initConfigHomePage(self): module = Module(self.visitHomePage, u"首页") module.module_id = "module_home_page" module.appendUrl("http://211.141.74.198:8081/aiccips/") module.appendHeaders({ 'Connection': 'keep-alive', 'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh-TW;q=0.4', 'Accept-Encoding': 'gzip, deflate, sdch', 'Cache-Control': 'max-age=0', 'Referer': 'http://211.141.74.198:8081/aiccips/', 'Host': '211.141.74.198:8081', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0' }) module.appendCookie("cookie") module.appendOutput("csrf", ".//input[@name='_csrf']/@value", OutputType.LIST) module.appendMiddleValueMonitor("csrf") module.addSleep(Sleep(3)) self.module_manager.appendSubModule(module, True)
def initConfigSearchList(self): module = Module(self.visitSearchList, u"搜索列表") module.appendUrl('http://211.141.74.198:8081/aiccips/pub/indsearch') module.appendHeaders({ 'Connection': 'keep-alive', 'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh-TW;q=0.4', 'Accept-Encoding': 'gzip, deflate', 'Cache-Control': 'max-age=0', 'Referer': 'http://211.141.74.198:8081/aiccips/', 'Host': '211.141.74.198:8081', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0' }) module.appendWebMethod("post") module.appendPostData( lambda csrf, yzm, company_key: { 'kw': company_key, '_csrf': csrf[-1], # 参数不为空由首页输出模块保证,且此参数为必选参数,故未做判断直接使用 'secode': getMd5WithString(yzm) }) module.appendCookie("cookie") module.appendOutput("url_list", ".//*[@class='list']/ul/li/a/@href", OutputType.LIST) module.appendOutput("name_list", ".//*[@class='list']/ul/li/a/text()", OutputType.LIST) module.appendOutput( name="search_list", type=OutputType.FUNCTION, function=lambda url_list, name_list: zip(url_list, name_list)) module.addEvent( Event(EventType.EXCEPTION_OCCURED, retry_times=100, redo_module="module_cookie")) module.addEvent( Event(EventType.OUTPUT_NOT_SATISFIED, retry_times=100, redo_module="module_cookie")) module.addEvent( Event(EventType.ASSERT_FAILED, retry_times=0, assert_function=lambda: False if self.report.access_type == SeedAccessType.NON_COMPANY else True)) module.addSleep(Sleep(3)) self.module_manager.appendSubModule(module)
def initAnnalsDetails(self, module_super): module = Module(self.visitQynb, u"获取年报详情") module.module_id = "get_annals_detail" def prepare(annal): query_dict = {} if annal and len(annal) >= 2: query_dict["annals_url"] = str(annal[0]) name = str(annal[1].strip('\r\n\t')) query_dict["nb_name"] = filter(str.isdigit, name) return query_dict module.appendInput(InputType.FUNCTION, prepare) def getUrl(annals_url): if "http" in annals_url: return annals_url else: return u'http://211.141.74.198:8081/' + annals_url module.appendUrl(getUrl) module.appendHeaders({ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch', 'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh-TW;q=0.4', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Host': '211.141.74.198:8081' }) module.appendWebMethod("get") module.appendCookie("cookie") module.addSleep(Sleep(3)) module.addEvent( Event(EventType.EXCEPTION_OCCURED, retry_times=100, redo_module="get_annals_list")) module_super.appendSubModule(module)
def initAnnalsList(self, module_super): module = Module(self.visitQynbList, u"获取年报列表") module.module_id = "get_annals_list" module.appendUrl( lambda params: 'http://211.141.74.198:8081/aiccips/pub/qygsdetail/' + params[1] + '/' + params[0]) module.appendHeaders({ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch', 'Accept-Language': 'en-US,en;q=0.8,zh-CN;q=0.6,zh-TW;q=0.4', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Host': '211.141.74.198:8081' }) module.appendWebMethod("get") module.appendCookie("cookie") module.addSleep(Sleep(3)) module.appendOutput("annals_urls", ".//*[@id='qiyenianbao']/table/tr/td[2]/a/@href", OutputType.LIST, show_up=OutputParameterShowUpType.OPTIONAL) module.appendOutput("annals_names", ".//*[@id='qiyenianbao']/table/tr/td[2]/a/text()", OutputType.LIST, show_up=OutputParameterShowUpType.OPTIONAL) module.appendOutput(name="annals_list", type=OutputType.FUNCTION, function=lambda annals_urls, annals_names: zip( annals_urls, annals_names), show_up=OutputParameterShowUpType.OPTIONAL) module.addEvent( Event(EventType.EXCEPTION_OCCURED, retry_times=100, redo_module="get_annals_list")) module_super.appendSubModule(module)