政府采购-详情页.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on 2025-05-20
  4. ---------
  5. @summary: 湖南省公共资源交易服务平台新网址
  6. ---------
  7. @author: lzz
  8. """
  9. import feapder
  10. from items.spider_item import DataBakItem
  11. import requests
  12. headers = {
  13. "Accept": "application/json, text/plain, */*",
  14. "Accept-Language": "zh-CN,zh;q=0.9",
  15. "Cache-Control": "no-cache",
  16. "Connection": "keep-alive",
  17. "Pragma": "no-cache",
  18. "Referer": "https://hnsbenji.hnsggzy.com/",
  19. "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",
  20. }
  21. def ggxx(hid,proxies=False):
  22. url = f"https://hnsbenji.hnsggzy.com/tradeApi/governmentPurchase/projectInformation/selectAnnouncementInformation/{hid}"
  23. try:
  24. res = requests.get(url, headers=headers, timeout=30, proxies=proxies, verify=False)
  25. res_data = res.json().get('data').get('governmentProcureAnnouncementInformation')[0]
  26. except:
  27. res_data = {}
  28. return res_data
  29. class Details(feapder.BiddingDetailSpider):
  30. def start_requests(self):
  31. data_list = self.get_tasks_by_rabbitmq(limit=100)
  32. for item in data_list:
  33. request_params = item.get("request_params")
  34. timeout = request_params.pop('timeout', 10)
  35. yield feapder.Request(url=item.get("parse_url"), item=item,
  36. files_info=item.get("files"),
  37. deal_detail=item.get("deal_detail"), timeout=timeout,
  38. callback=eval(item.get("parse")),
  39. **request_params)
  40. def detail_get(self, request, response):
  41. items = request.item
  42. list_item = DataBakItem(**items)
  43. detail_info = response.json.get('data')
  44. bdxx = detail_info.get('GovernmentProcureSectionInformationList')
  45. bdxx_html = ""
  46. if bdxx:
  47. index = 1
  48. for info in bdxx:
  49. temp = f'''
  50. <tr>
  51. <td>{index}</td>
  52. <td>{info.get('purchaseSectionCode')}</td>
  53. <td>{info.get('purchaseSectionName')}</td>
  54. <td>{info.get('sectionBudget','')} 元</td>
  55. <td>{info.get('tenderType')}</td>
  56. <td>{info.get('controlPrice')}</td>
  57. <td>{info.get('unifiedDealCode')}</td>
  58. <td>{info.get('purchaseQualification')}</td>
  59. <td>{info.get('purchaseSectionContent')}</td>
  60. </tr>
  61. '''
  62. index +=1
  63. bdxx_html += temp
  64. xmxx = detail_info.get('governmentProcurementProjectInformation')
  65. if xmxx.get('isProject') == 1:
  66. isProject = "是"
  67. else:
  68. isProject = "否"
  69. html = f'''
  70. <table class="table-list">
  71. <tr>
  72. <th>采购项目名称</th>
  73. <td colspan="3">{xmxx.get('purchaseProjectName')}</td>
  74. </tr>
  75. <tr>
  76. <th>采购项目编号</th>
  77. <td colspan="3">{xmxx.get('purchaseProjectCode')}</td>
  78. </tr>
  79. <tr>
  80. <th>项目所在行政区</th>
  81. <td>{xmxx.get('regionCode')}</td>
  82. <th>采购项目类型</th>
  83. <td>{xmxx.get('tenderProjectType')}</td>
  84. </tr>
  85. <tr>
  86. <th>采购人名称</th>
  87. <td>{xmxx.get('purchaserName')}</td>
  88. <th>采购人代码</th>
  89. <td>{xmxx.get('purchaserCode')}</td>
  90. </tr>
  91. <tr>
  92. <th>采购代理机构名称</th>
  93. <td>{xmxx.get('purchaserAgencyName')}</td>
  94. <th>采购代理机构联系人</th>
  95. <td>{xmxx.get('purchaserAgencyConnector')}</td>
  96. </tr>
  97. <tr>
  98. <th>采购代理机构联系电话</th>
  99. <td>{xmxx.get('purchaserAgencyInformation')}</td>
  100. <th>项目预算</th>
  101. <td><span>{xmxx.get('programBudget')}<span>元</span></span></td>
  102. </tr>
  103. <tr></tr>
  104. <tr>
  105. <th>是否PPP项目</th>
  106. <td>{isProject}</td>
  107. <th>采购方式</th>
  108. <td>{xmxx.get('purchaserMode')}</td>
  109. </tr>
  110. </table>
  111. <table>
  112. <thead>
  113. <tr>序号</tr>
  114. <tr>采购项目子包编号</tr>
  115. <tr>采购项目子包名称称</tr>
  116. <tr>分包预算</tr>
  117. <tr>招标类别</tr>
  118. <tr>控制价(最高限价)</tr>
  119. <tr>统一交易标识码</tr>
  120. <tr>投标人资格条件</tr>
  121. <tr>标段(包)内容</tr>
  122. </thead>
  123. <tbody>
  124. {bdxx_html}
  125. </tbody>
  126. </table>
  127. '''
  128. hid = request.url.split('/')[-1]
  129. ggxx_info = ggxx(hid,proxies=request.proxies())
  130. if xmxx.get('isRemoteEvaluation') == 1:
  131. isRemoteEvaluation = "是"
  132. else:
  133. isRemoteEvaluation = "否"
  134. if ggxx_info:
  135. ggxx_html = f'''
  136. <table class="table-list">
  137. <tr>
  138. <th>公告标题</th>
  139. <td colspan="3">{ggxx_info.get('noticeName')}</td>
  140. </tr>
  141. <tr>
  142. <th>公告类型</th>
  143. <td>{ggxx_info.get('bulletinType')}</td>
  144. <th>公告发布时间</th>
  145. <td>{ggxx_info.get('noticeSendTime')}</td>
  146. </tr>
  147. <tr>
  148. <th>公告发布责任人</th>
  149. <td>{ggxx_info.get('bulletinDuty')}</td>
  150. <th>公告子包数量</th>
  151. <td>{ggxx_info.get('bulletinBidNum')}</td>
  152. </tr>
  153. <tr>
  154. <th>是否远程异地评标</th>
  155. <td colspan="3">{isRemoteEvaluation}</td>
  156. </tr>
  157. <tr>
  158. <th>公告内容</th>
  159. <td colspan="3">{ggxx_info.get('noticeContent')}</td>
  160. </tr>
  161. </table>
  162. '''
  163. else:
  164. ggxx_html = ""
  165. list_item.contenthtml = html.replace('None','-') + ggxx_html.replace('None','-')
  166. yield list_item
  167. if __name__ == "__main__":
  168. spider = Details(redis_key="lzz:hnsggzyjyfwptxwz_zfcg").start()