|
@@ -0,0 +1,37 @@
|
|
|
+from common.execptions import QccError
|
|
|
+from common.tools import html2element
|
|
|
+from crawler.download import Downloader
|
|
|
+
|
|
|
+
|
|
|
+class QccService(Downloader):
|
|
|
+
|
|
|
+ def get_site(self, name: str):
|
|
|
+ site = '-'
|
|
|
+ headers = {
|
|
|
+ "authority": "www.qcc.com",
|
|
|
+ "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|
|
+ "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
|
+ "cache-control": "no-cache",
|
|
|
+ "pragma": "no-cache",
|
|
|
+ "upgrade-insecure-requests": "1",
|
|
|
+ "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
|
|
|
+ }
|
|
|
+ cookies = {
|
|
|
+ "qcc_did": "d6af577d-b7e1-455b-a02d-bdfbd681d0db",
|
|
|
+ "UM_distinctid": "17fde8eb058bcc-0f0dac963d063e-1c3a645d-1aeaa0-17fde8eb059107d",
|
|
|
+ "QCCSESSID": "19da28dabd9a95bfa3354284a3",
|
|
|
+ "CNZZDATA1254842228": "1319079473-1648702017-https%253A%252F%252Fwww.google.com%252F%7C1650861011",
|
|
|
+ "acw_tc": "74d3df2616508705426597994e18592eed62a8f8e51fb14fafa552e27d"
|
|
|
+ }
|
|
|
+ url = "https://www.qcc.com/web/search"
|
|
|
+ params = {"key": name.strip()}
|
|
|
+ response = self.get(url, headers=headers, cookies=cookies, params=params)
|
|
|
+ if response.status_code != 200:
|
|
|
+ raise QccError(reason='企查查搜索接口调用失败')
|
|
|
+ element = html2element(response.text)
|
|
|
+ nodes = element.xpath('//table[@class="ntable ntable-list"]//tr[1]/td[3]/div[1]/div[4]/div[2]/span[3]/span/child::*')
|
|
|
+ if len(nodes) > 0:
|
|
|
+ sub_node = nodes[0]
|
|
|
+ site = "".join("".join(sub_node.xpath('./text()')).split())
|
|
|
+ print(site)
|
|
|
+ return site
|