123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- # -*- coding: utf-8 -*-
- """
- Created on 2025-05-20
- ---------
- @summary: 湖南省公共资源交易服务平台新网址
- ---------
- @author: lzz
- """
- import feapder
- from items.spider_item import DataBakItem
- import requests
- headers = {
- "Accept": "application/json, text/plain, */*",
- "Accept-Language": "zh-CN,zh;q=0.9",
- "Cache-Control": "no-cache",
- "Connection": "keep-alive",
- "Pragma": "no-cache",
- "Referer": "https://hnsbenji.hnsggzy.com/",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
- }
- def ggxx(hid,proxies=False):
- url = f"https://hnsbenji.hnsggzy.com/tradeApi/governmentPurchase/projectInformation/selectAnnouncementInformation/{hid}"
- try:
- res = requests.get(url, headers=headers, timeout=30, proxies=proxies, verify=False)
- res_data = res.json().get('data').get('governmentProcureAnnouncementInformation')[0]
- except:
- res_data = {}
- return res_data
- class Details(feapder.BiddingDetailSpider):
- def start_requests(self):
- data_list = self.get_tasks_by_rabbitmq(limit=100)
- for item in data_list:
- request_params = item.get("request_params")
- timeout = request_params.pop('timeout', 10)
- yield feapder.Request(url=item.get("parse_url"), item=item,
- files_info=item.get("files"),
- deal_detail=item.get("deal_detail"), timeout=timeout,
- callback=eval(item.get("parse")),
- **request_params)
- def detail_get(self, request, response):
- items = request.item
- list_item = DataBakItem(**items)
- detail_info = response.json.get('data')
- bdxx = detail_info.get('GovernmentProcureSectionInformationList')
- bdxx_html = ""
- if bdxx:
- index = 1
- for info in bdxx:
- temp = f'''
- <tr>
- <td>{index}</td>
- <td>{info.get('purchaseSectionCode')}</td>
- <td>{info.get('purchaseSectionName')}</td>
- <td>{info.get('sectionBudget','')} 元</td>
- <td>{info.get('tenderType')}</td>
- <td>{info.get('controlPrice')}</td>
- <td>{info.get('unifiedDealCode')}</td>
- <td>{info.get('purchaseQualification')}</td>
- <td>{info.get('purchaseSectionContent')}</td>
- </tr>
- '''
- index +=1
- bdxx_html += temp
- xmxx = detail_info.get('governmentProcurementProjectInformation')
- if xmxx.get('isProject') == 1:
- isProject = "是"
- else:
- isProject = "否"
- html = f'''
- <table class="table-list">
- <tr>
- <th>采购项目名称</th>
- <td colspan="3">{xmxx.get('purchaseProjectName')}</td>
- </tr>
- <tr>
- <th>采购项目编号</th>
- <td colspan="3">{xmxx.get('purchaseProjectCode')}</td>
- </tr>
- <tr>
- <th>项目所在行政区</th>
- <td>{xmxx.get('regionCode')}</td>
- <th>采购项目类型</th>
- <td>{xmxx.get('tenderProjectType')}</td>
- </tr>
- <tr>
- <th>采购人名称</th>
- <td>{xmxx.get('purchaserName')}</td>
- <th>采购人代码</th>
- <td>{xmxx.get('purchaserCode')}</td>
- </tr>
- <tr>
- <th>采购代理机构名称</th>
- <td>{xmxx.get('purchaserAgencyName')}</td>
- <th>采购代理机构联系人</th>
- <td>{xmxx.get('purchaserAgencyConnector')}</td>
- </tr>
- <tr>
- <th>采购代理机构联系电话</th>
- <td>{xmxx.get('purchaserAgencyInformation')}</td>
- <th>项目预算</th>
- <td><span>{xmxx.get('programBudget')}<span>元</span></span></td>
- </tr>
- <tr></tr>
- <tr>
- <th>是否PPP项目</th>
- <td>{isProject}</td>
- <th>采购方式</th>
- <td>{xmxx.get('purchaserMode')}</td>
- </tr>
- </table>
-
- <table>
- <thead>
- <tr>序号</tr>
- <tr>采购项目子包编号</tr>
- <tr>采购项目子包名称称</tr>
- <tr>分包预算</tr>
- <tr>招标类别</tr>
- <tr>控制价(最高限价)</tr>
- <tr>统一交易标识码</tr>
- <tr>投标人资格条件</tr>
- <tr>标段(包)内容</tr>
- </thead>
- <tbody>
- {bdxx_html}
- </tbody>
- </table>
- '''
- hid = request.url.split('/')[-1]
- ggxx_info = ggxx(hid,proxies=request.proxies())
- if xmxx.get('isRemoteEvaluation') == 1:
- isRemoteEvaluation = "是"
- else:
- isRemoteEvaluation = "否"
- if ggxx_info:
- ggxx_html = f'''
- <table class="table-list">
- <tr>
- <th>公告标题</th>
- <td colspan="3">{ggxx_info.get('noticeName')}</td>
- </tr>
- <tr>
- <th>公告类型</th>
- <td>{ggxx_info.get('bulletinType')}</td>
- <th>公告发布时间</th>
- <td>{ggxx_info.get('noticeSendTime')}</td>
- </tr>
- <tr>
- <th>公告发布责任人</th>
- <td>{ggxx_info.get('bulletinDuty')}</td>
- <th>公告子包数量</th>
- <td>{ggxx_info.get('bulletinBidNum')}</td>
- </tr>
- <tr>
- <th>是否远程异地评标</th>
- <td colspan="3">{isRemoteEvaluation}</td>
- </tr>
- <tr>
- <th>公告内容</th>
- <td colspan="3">{ggxx_info.get('noticeContent')}</td>
- </tr>
- </table>
- '''
- else:
- ggxx_html = ""
- list_item.contenthtml = html.replace('None','-') + ggxx_html.replace('None','-')
- yield list_item
- if __name__ == "__main__":
- spider = Details(redis_key="lzz:hnsggzyjyfwptxwz_zfcg").start()
|