|
@@ -9,27 +9,13 @@ Created on 2025-02-15
|
|
|
import json
|
|
|
from collections import namedtuple
|
|
|
|
|
|
-import execjs
|
|
|
import feapder
|
|
|
from items.njpc_item import NjpcListItem
|
|
|
|
|
|
+from utils import token as get_token
|
|
|
|
|
|
-def get_token():
|
|
|
- ex_js = '''
|
|
|
- function token() {
|
|
|
- var Ie = 911
|
|
|
- , Pe = 20170706
|
|
|
- , Fe = 1e9;
|
|
|
- extoken = (n = Math.floor(10 * Math.random()) * Fe,
|
|
|
- (((new Date).getTime() % Fe + n) * Ie + Pe).toString(36))
|
|
|
- return extoken
|
|
|
- }
|
|
|
- '''
|
|
|
- ctx = execjs.compile(ex_js)
|
|
|
- return ctx.call('token')
|
|
|
|
|
|
-
|
|
|
-class NjpcSpider(feapder.PlanToBuildListSpider):
|
|
|
+class Spider(feapder.PlanToBuildListSpider):
|
|
|
|
|
|
def start_callback(self):
|
|
|
Menu = namedtuple('Menu', ['channel', 'code', 'crawl_page'])
|
|
@@ -101,9 +87,10 @@ class NjpcSpider(feapder.PlanToBuildListSpider):
|
|
|
info_list = response.json.get('data').get('list')
|
|
|
for info in info_list:
|
|
|
approvecode = info.get('project_code') or info.get('_id')
|
|
|
- detail_href = "https://tzxm.hubei.gov.cn/xxgk?" + approvecode
|
|
|
projectname = info.get('project_name').strip()
|
|
|
publish_time = info.get('declaration_date').strip()
|
|
|
+ url = "/".join(["https://tzxm.hubei.gov.cn/xxgk", publish_time, approvecode])
|
|
|
+ detail_href = f"{url}?q={menu['channel']}"
|
|
|
owner = info.get('unit_name')
|
|
|
|
|
|
area = "湖北" # 省份
|
|
@@ -125,14 +112,13 @@ class NjpcSpider(feapder.PlanToBuildListSpider):
|
|
|
data_item.district = district # 城市 默认为空
|
|
|
data_item.parser_url = "https://tzxm.hubei.gov.cn:7216/api/proxy/custom/hb/hb_aiapp/xMod/filing_search/customShow"
|
|
|
data_item.href = detail_href # 详情链接
|
|
|
- ddata = {
|
|
|
+ json_str = json.dumps({
|
|
|
"_id": info.get('_id'),
|
|
|
"switchLoginRequired": "off",
|
|
|
"screenKey": "SCR_l4xunf59n2"
|
|
|
- }
|
|
|
- ddata = json.dumps(ddata)
|
|
|
+ })
|
|
|
data_item.request_params = {
|
|
|
- "data": ddata,
|
|
|
+ "data": json_str,
|
|
|
"method": "POST"
|
|
|
}
|
|
|
data_item.parser = "detail_get"
|
|
@@ -143,4 +129,4 @@ class NjpcSpider(feapder.PlanToBuildListSpider):
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
- NjpcSpider(redis_key="lzz:hbzwfww_bacx").start()
|
|
|
+ Spider(redis_key="lzz:hbzwfww_bacx").start()
|