123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- # -*- coding: utf-8 -*-
- """
- Created on 2024-03-15
- ---------
- @summary: 湖北政务服务网-备案查询
- ---------
- @author: lzz
- """
- import feapder
- from items.njpc_item import DataNjpcItem
- from hbzwfww_area_dict import area_dict
- from utils import token as get_token
- class Spider(feapder.PlanToBuildDetailSpider):
- def start_requests(self):
- data_list = self.get_tasks_by_rabbitmq(limit=50)
- for item in data_list:
- # log.debug(item)
- request_params = item.get("request_params")
- timeout = request_params.pop('timeout', 10)
- yield feapder.Request(url=item.get("parser_url"),
- item=item,
- deal_detail=item.get("deal_detail"),
- callback=item.get("parser"),
- timeout=timeout,
- **request_params)
- def download_midware(self, request):
- token = get_token()
- request.headers = {
- "Accept": "application/json, text/plain, */*",
- "Accept-Language": "zh-CN,zh;q=0.9",
- "Connection": "keep-alive",
- "Content-Type": "application/json",
- "Origin": "http://zwfw.hubei.gov.cn",
- "Referer": "http://zwfw.hubei.gov.cn/",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
- "authtoken": "null",
- "compkey": "hb",
- "extoken": f"{token}",
- }
- def detail_get(self, request, response):
- items = request.item
- data_item = DataNjpcItem(**items)
- detail_info = response.json.get('data')
- baz_dict = {"BA01": "尚未审核", "BA02": "有效", "BA03": "已注销", "BA04": "无此信息"}
- ba_examine_status = baz_dict.get(detail_info.get('hb_Record_card'))
- unit_nature_dict = {"A00006": "集体企业", "A00001": "政府机关", "A00007": "私营企业", "A00012": "其他",
- "A00004": "国有及国有控股企业", "A00011": "村民委员会", "A00005": "股份制企业",
- "A00008": "港澳台及外资企业"}
- unit_nature = unit_nature_dict.get(detail_info.get('unit_nature')) or "暂无内容"
- ba_apply_status_dict = {"A00001": "备案注销", "A00002": "变更备案证", "A00003": "生成备案证", }
- ba_apply_status = ba_apply_status_dict.get(detail_info.get('ba_apply_status')) or "暂无内容"
- construct_nature_dict = {"4": "技改及其他", "0": "新建", "1": "扩建", "2": "迁建", "3": "改建", }
- construct_nature = construct_nature_dict.get(detail_info.get('construct_nature')) or "暂无内容"
- project_address = ''
- if detail_info.get('project_address'):
- area_code = detail_info.get('project_address')[0]
- darea = ""
- dcity = ""
- ddistrict = ""
- for tf in area_dict:
- if area_code and len(area_code) > 0:
- if area_code[0] == tf.get('_keye'):
- darea = tf.get('name')
- if len(area_code) > 1:
- for ts in tf.get('children'):
- if area_code[1] == ts.get('_keye'):
- dcity = ts.get('name')
- if len(area_code) > 2:
- for tt in ts.get('children'):
- if area_code[2] == tt.get('_keye'):
- ddistrict = tt.get('name')
- project_address = f"{darea}/{dcity}/{ddistrict}"
- html = f'''
- <form>
- <div>
- <div>
- <div><span>项目名称</span></div>
- <div><span>{detail_info.get('project_name')}</span></div>
- </div>
- <div>
- <div><span>项目代码</span></div>
- <div><span>{detail_info.get('project_code')}</span></div>
- </div>
- <div>
- <div><span>建设内容及规</span></div>
- <div><span>{detail_info.get('description')}</span></div>
- </div>
- <div>
- <div><span>项目单位</span></div>
- <div><span>{detail_info.get('unit_name')}</span></div>
- </div>
- <div>
- <div><span>法人代表姓名</span></div>
- <div><span>{detail_info.get('legal_name')}</span></div>
- </div>
- <div>
- <div><span>项目单位性质</span></div>
- <div><span>{unit_nature}</span></div>
- </div>
- <div>
- <div><span>所属行政区划</span></div>
- <div><span>{project_address}</span></div>
- </div>
- <div>
- <div><span>项目总投资</span></div>
- <div><span>{detail_info.get('amount')}</span></div>
- </div>
- <div>
- <div><span>建设性质</span></div>
- <div><span>{construct_nature}</span></div>
- </div>
- <div>
- <div><span>拟开工时间</span></div>
- <div><span>{detail_info.get('nstart_date')}</span></div>
- </div>
- <div>
- <div><span>备案审核状态</span></div>
- <div><span>{ba_examine_status}</span></div>
- </div>
- <div>
- <div><span>备案证状态</span></div>
- <div><span>{ba_apply_status}</span></div>
- </div>
- <div>
- <div><span>申报日期</span></div>
- <div><span>{detail_info.get('declaration_date')}</span></div>
- </div>
- </div>
- </form>
- '''
- data_item.contenthtml = html.replace('None', '暂无内容').replace('//', '')
- total_investment = detail_info.get('amount') or ''
- if total_investment:
- data_item.total_investment = str(total_investment) + "万元"
- yield data_item
- if __name__ == '__main__':
- Spider(redis_key="lzz:hbzwfww_bacx").start()
|