异步第三方资源抓取
Last updated
2023-07-14 16:41:26
{"value":"## **\u63cf\u8ff0**\n\n\u672c\u63a5\u53e3\u7528\u4e8e\u4ece\u6307\u5b9a URL \u6293\u53d6\u8d44\u6e90\uff0c\u5e76\u5c06\u8be5\u8d44\u6e90\u5b58\u50a8\u5230\u6307\u5b9a\u7a7a\u95f4\u4e2d\u3002\u6bcf\u6b21\u53ea\u6293\u53d6\u4e00\u4e2a\u6587\u4ef6\uff0c\u6293\u53d6\u65f6\u53ef\u4ee5\u6307\u5b9a\u4fdd\u5b58\u7a7a\u95f4\u540d\u548c\u6700\u7ec8\u8d44\u6e90\u540d\u3002\n\n\n\n## **\u53d1\u8d77\u4efb\u52a1:**\n\n## **\u8bf7\u6c42**\n\n### **\u8bf7\u6c42\u8bed\u6cd5**\n\n```\nPOST \/sisyphus\/fetch HTTP\/1.1\nHost: api-<Region>.qiniuapi.com\nContent-Type: application\/json\nX-Qiniu-Date: 20060102T150405Z\nAuthorization: Qiniu <AccessToken>\nBody:\n{\n \"url\" : \"<url>\",\n \"host\" : \"<host>\",\n \"bucket\": \"<bucket>\",\n \"key\": \"<key>\",\n \"md5\": \"<md5>\",\n \"callbackurl\": \"<callbackurl>\",\n \"callbackbody\": \"<callbackbody>\",\n \"callbackbodytype\": \"<callbackbodytype>\",\n \"file_type\":<file_type>\n ...\n}\n```\n\n\u4f7f\u7528\u8bf4\u660e\uff1a\n\n- \u6293\u53d6\u52a8\u4f5c\u662f\u5f02\u6b65\u64cd\u4f5c\uff0c\u63a5\u53d7\u5230\u6293\u53d6\u8bf7\u6c42\u540e\u670d\u52a1\u7aef\u76f4\u63a5\u8fd4\u56de\u6210\u529f\uff0c\u8d44\u6e90\u4f1a\u5728\u540e\u53f0\u8fdb\u884c\u6293\u53d6\u540e\u5b58\u5165\u5b58\u50a8\uff0c\u5e76\u4ea7\u751f\u4e00\u4e2a\u56de\u8c03\u8bf7\u6c42\u901a\u77e5\u4e1a\u52a1\u670d\u52a1\u5668\uff08\u5982\u679c\u5b58\u5728\u56de\u8c03\u53c2\u6570\uff09\u3002\n- \u56e0\u4e3a\u5404\u79cd\u539f\u56e0\u6293\u53d6\u5931\u8d25\u65f6\u4f1a\u4ea7\u751f\u4e00\u4e2a json \u683c\u5f0f\u7684***\u7279\u6b8a\u56de\u8c03\\***\u901a\u77e5\u4e1a\u52a1\u670d\u52a1\u5668\u3002\n- \u5982\u679c\u88ab\u6293\u53d6\u7684\u6e90\u7ad9\u5c4f\u853d\uff08\u5c4f\u853d\u53ef\u80fd\u662f\u6293\u53d6\u6e90\u7ad9\u6709 IP\u3001UA \u7b49\u9650\u5236\u7b56\u7565\uff09\u6765\u81ea\u4e03\u725b\u7684\u6293\u53d6\u64cd\u4f5c\uff0c\u90a3\u4e48\u4e0d\u80fd\u786e\u4fdd\u4e00\u5b9a\u53ef\u4ee5\u6293\u53d6\u6210\u529f\u3002\n\n### **\u8bf7\u6c42\u53c2\u6570**\n\n\u8be5\u8bf7\u6c42\u64cd\u4f5c\u7684\u53c2\u6570\u4e3a\u7a7a\uff0c\u8bf7\u53c2\u8003\u64cd\u4f5c\u5185\u5bb9\u4e2d\u7684\u53c2\u6570\u3002\n\n\n\n### **\u8bf7\u6c42\u5934**\n\n| \u5934\u90e8\u540d\u79f0 | \u5fc5\u586b | \u8bf4\u660e | |\n| :------------ | :--- | :----------------------------------------------------------- | ---------------- |\n| Host | \u662f | `api-<Region>.qiniuapi.com` \u4e2d\u7684 `<Region>` \u4e3a\u4e03\u725b\u5404\u533a\u57df ID\uff0c\u8bf7\u53c2\u8003CDNCDLOUD\u652f\u6301\u7684 \u533a\u57df\u5217\u8868 | |\n| Authorization | \u662f | \u8be5\u53c2\u6570\u5e94\u4e25\u683c\u6309\u7167\u7ba1\u7406\u51ed\u8bc1\u683c\u5f0f\u8fdb\u884c\u586b\u5145\uff0c\u5426\u5219\u4f1a\u8fd4\u56de 401 \u9519\u8bef\u7801\u4e00\u4e2a\u5408\u6cd5\u7684 Authorization \u503c\u5e94\u7c7b\u4f3c\u4e8e\uff1a`Qiniu QNJi_bYJlmO5LeY08FfoNj9w_r7...` | |\n| | \u5176\u4ed6 | | \u8bf7\u67e5\u9605\u516c\u5171\u8bf7\u6c42\u5934 |\n\n\n\n### **\u8bf7\u6c42\u5185\u5bb9**\n\n| \u53c2\u6570\u540d\u79f0 | \u7c7b\u578b | \u9ed8\u8ba4\u503c | \u5fc5\u586b | \u8bf4\u660e |\n| ---------------- | ------ | ------ | ---- | ------------------------------------------------------------ |\n| url | string | N\/A | \u662f | \u9700\u8981\u6293\u53d6\u7684 url,\u652f\u6301\u8bbe\u7f6e\u591a\u4e2a\u7528\u4e8e\u9ad8\u53ef\u7528,\u4ee5';'\u5206\u9694,\u5f53\u6307\u5b9a\u591a\u4e2a url \u65f6\u53ef\u4ee5\u5728\u524d\u4e00\u4e2a url \u6293\u53d6\u5931\u8d25\u65f6\u91cd\u8bd5\u4e0b\u4e00\u4e2a |\n| bucket | string | N\/A | \u662f | \u6240\u5728\u533a\u57df\u7684 bucket |\n| host | string | \u7a7a | \u5426 | \u4ece\u6307\u5b9a url \u4e0b\u8f7d\u6570\u636e\u65f6\u4f7f\u7528\u7684 Host |\n| key | string | \u7a7a | \u5426 | \u6587\u4ef6\u5b58\u50a8\u7684 key,\u4e0d\u4f20\u5219\u4f7f\u7528\u6587\u4ef6 hash \u4f5c\u4e3a key |\n| md5 | string | \u7a7a | \u5426 | \u6587\u4ef6 md5,\u4f20\u5165\u4ee5\u540e\u4f1a\u5728\u5b58\u5165\u5b58\u50a8\u65f6\u5bf9\u6587\u4ef6\u505a\u6821\u9a8c\uff0c\u6821\u9a8c\u5931\u8d25\u5219\u4e0d\u5b58\u5165\u6307\u5b9a\u7a7a\u95f4 |\n| etag | string | \u7a7a | \u5426 | \u6587\u4ef6 etag,\u4f20\u5165\u4ee5\u540e\u4f1a\u5728\u5b58\u5165\u5b58\u50a8\u65f6\u5bf9\u6587\u4ef6\u505a\u6821\u9a8c\uff0c\u6821\u9a8c\u5931\u8d25\u5219\u4e0d\u5b58\u5165\u6307\u5b9a\u7a7a\u95f4,\u76f8\u5173\u7b97\u6cd5\u53c2\u8003 (https:\/\/github.com\/CDNCloud-com\/qetag) |\n| callbackurl | string | \u7a7a | \u5426 | \u56de\u8c03 URL\uff0c\u8be6\u7ec6\u89e3\u91ca\u8bf7\u53c2\u8003\u4e0a\u4f20\u7b56\u7565\u4e2d\u7684callbackUrl |\n| callbackbody | string | \u7a7a | \u5426 | \u56de\u8c03 Body\uff0c\u5982\u679c callbackurl \u4e0d\u4e3a\u7a7a\u5219\u5fc5\u987b\u6307\u5b9a\u3002\u4e0a\u4f20\u6210\u529f\u540e\uff0c\u4e03\u725b\u4e91\u5411\u4e1a\u52a1\u670d\u52a1\u5668\u53d1\u9001 Content-Type: application\/x-www-form-urlencoded \u7684 POST \u8bf7\u6c42\u3002\u4e1a\u52a1\u670d\u52a1\u5668\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u8bfb\u53d6\u8bf7\u6c42\u7684 query \u6765\u83b7\u5f97\u8be5\u5b57\u6bb5\uff0c\u652f\u6301\u9b54\u6cd5\u53d8\u91cf\u3001\u4f46\u4e0d\u652f\u6301\u81ea\u5b9a\u4e49\u53d8\u91cf\u3002callbackBody \u8981\u6c42\u662f\u5408\u6cd5\u7684 url query string\u3002\u4f8b\u5982 key=$(key)&hash=$(etag)&w=$(imageInfo.width)&h=$(imageInfo.height)\u3002\u5982\u679c callbackBodyType \u6307\u5b9a\u4e3a application\/json\uff0c\u5219 callbackBody \u5e94\u4e3a json \u683c\u5f0f\uff0c\u4f8b\u5982:{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"w\":\"$(imageInfo.width)\",\"h\":\"$(imageInfo.height)\"}\u3002 |\n| callbackbodytype | string | \u7a7a | \u5426 | \u56de\u8c03 Body \u5185\u5bb9\u7c7b\u578b,\u9ed8\u8ba4\u4e3a\"application\/x-www-form-urlencoded\"\uff0c\u8be6\u7ec6\u89e3\u91ca\u8bf7\u53c2\u8003\u4e0a\u4f20\u7b56\u7565\u4e2d\u7684callbackBodyType\u3002 |\n| callbackhost | string | \u7a7a | \u5426 | \u56de\u8c03\u65f6\u4f7f\u7528\u7684 Host |\n| file_type | int | 0 | \u5426 | \u5b58\u50a8\u6587\u4ef6\u7c7b\u578b 0:\u6807\u51c6\u5b58\u50a8(\u9ed8\u8ba4), 1:\u4f4e\u9891\u5b58\u50a8, 2:\u5f52\u6863\u5b58\u50a8, 3:\u6df1\u5ea6\u5f52\u6863\u5b58\u50a8 |\n| mode | string | \u7a7a | \u5426 | \u53ef\u9009\u586b\u2f0a m3u8\uff0c\u6b64\u65f6\u4f1a\u89e3\u6790 m3u8 \u5e76\u4e0b\u8f7d\u5bf9\u5e94 ts \u843d\u5b58\u50a8, \u5fc5\u987b\u6307\u5b9a key\u3002m3u8 \u6587\u4ef6\u7684\u89e3\u6790\uff0c\u53ea\u652f\u6301\u76f8\u5bf9\u8def\u5f84\u6a21\u5f0f\uff1ats \u6587\u4ef6\u548c m3u8 \u6587\u4ef6\u5c06\u4fdd\u5b58\u5728\u6307\u5b9a\u7684\u540c\u4e00\u76ee\u5f55\u4e0b\u3002 |\n| ignore_same_key | bool | false | \u5426 | \u5982\u679c\u5df2\u5b58\u5728\u540c\u540d\u2f42\u4f1a\u91cd\u8bd5\u6293\u53d6\u3002\u5f53\u4e3a true \u65f6\uff0c\u5982\u679c\u7a7a\u95f4\u4e2d\u5df2\u7ecf\u5b58\u5728\u540c\u540d\u6587\u4ef6\u5219\u653e\u5f03\u672c\u6b21\u6293\u53d6(\u4ec5\u5bf9\u6bd4 key\uff0c\u4e0d\u6821\u9a8c\u6587\u4ef6\u5185\u5bb9)\u3002 |\n\n\n\n\n\n## **\u54cd\u5e94**\n\n### **\u54cd\u5e94\u8bed\u6cd5**\n\n```\nHTTP\/1.1 200 OK\nContent-Type: application\/json\nCache-Control: no-store\nBody: \n{\n}\n```\n\n\n\n### **\u54cd\u5e94\u5934**\n\n| \u5934\u90e8\u540d\u79f0 | \u5fc5\u586b | \u8bf4\u660e |\n| :----------- | :--- | :----------------------------------------------------------- |\n| Content-Type | \u662f | \u6b63\u5e38\u60c5\u51b5\u4e0b\u8be5\u503c\u5c06\u88ab\u8bbe\u4e3a `application\/json`\uff0c\u8868\u793a\u8fd4\u56de JSON \u683c\u5f0f\u7684\u6587\u672c\u4fe1\u606f\u3002 |\n| \u5176\u4ed6 | | \u5176\u5b83\u53ef\u80fd\u8fd4\u56de\u7684\u5934\u90e8\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u516c\u5171\u54cd\u5e94\u5934\u3002 |\n\n\n\n### **\u54cd\u5e94\u5185\u5bb9**\n\n\u5982\u679c\u8bf7\u6c42\u6210\u529f\uff0c\u5219\u8fd4\u56de\n\n```\n{\"id\":\"<ID>\",\"wait\":<Wait>}\n```\n\n| \u53c2\u6570\u540d\u79f0 | \u8bf4\u660e |\n| -------- | ------------------------------------------------------------ |\n| id | \u5f02\u6b65\u4efb\u52a1Id |\n| wait | \u5f53\u524d\u4efb\u52a1\u524d\u9762\u7684\u6392\u961f\u4efb\u52a1\u6570\u91cf,0\u8868\u793a\u5f53\u524d\u4efb\u52a1\u6b63\u5728\u8fdb\u884c,-1\u8868\u793a\u4efb\u52a1\u5df2\u7ecf\u81f3\u5c11\u88ab\u5904\u7406\u8fc7\u4e00\u6b21\uff08\u53ef\u80fd\u4f1a\u8fdb\u5165\u91cd\u8bd5\u903b\u8f91\uff09 |\n\n\u5982\u679c\u6293\u53d6\u5931\u8d25\uff0c\u5219\u8fd4\u56de\u7279\u6b8a\u56de\u8c03\u6d88\u606f\u4f53\u683c\u5f0f \uff08\u7279\u6b8a\u56de\u8c03\u6d88\u606f\u4f53\u5305\u542b\u53d1\u8d77\u8bf7\u6c42\u65f6\u7684\u53c2\u6570\u548c\u9519\u8bef\u4fe1\u606f,\u793a\u4f8b\u4e0d\u5305\u542b\u6240\u6709\u53c2\u6570\uff09\n\n```\n{\n \"url\" : \"<url>\",\n \"bucket\": \"<bucket>\",\n \"key\": \"<key>\",\n \"md5\": \"<md5>\",\n \"callbackurl\": \"<callbackurl>\",\n \"callbackbody\": \"<callbackbody>\",\n \"callbackbodytype\": \"<callbackbodytype>\",\n \"file_type\":<file_type>,\n \"err\":\"<err>\",\n \"code\":<code>\n}\n```\n\n| \u53c2\u6570\u540d\u79f0 | \u8bf4\u660e |\n| -------- | -------- |\n| err | \u9519\u8bef\u4fe1\u606f |\n| code | \u9519\u8bef\u7801 |\n\n\n\n### **\u54cd\u5e94\u72b6\u6001\u7801**\n\n\u8be5\u64cd\u4f5c\u7684\u5b9e\u73b0\u4e0d\u4f1a\u8fd4\u56de\u7279\u6b8a\u9519\u8bef\u3002\u6709\u5173\u9519\u8bef\u548c\u9519\u8bef\u4ee3\u7801\u5217\u8868\u7684\u4e00\u822c\u4fe1\u606f\uff0c\u8bf7\u67e5\u9605\u9519\u8bef\u54cd\u5e94\u3002\n\n## **\u793a\u4f8b**\n\n### **\u8bf7\u6c42**\n\n**\u53d1\u8d77\u5f02\u6b65\u4efb\u52a1**\n\n```\nPOST \/sisyphus\/fetch HTTP\/1.1\nHost: api-z0.qiniuapi.com\nContent-Type: application\/json\nUser-Agent: Go-http-client\/1.1\nX-Qiniu-Date: 20060102T150405Z\nAuthorization: Qiniu j853F3bLkWl59I5BOkWm6q1Z1mZClpr9Z9CLfDE0:FwliyUEz-rL1rb9qVkd0xYosBng=\nBody:\n{\n \"url\" : \"http:\/\/www.qiniu.com\",\n \"bucket\": \"test\",\n \"key\": \"qiniu\",\n \"callbackurl\": \"http:\/\/www.qiniu.com\/callback\",\n \"callbackbody\": \"$(bucket)\"\n}\n```\n\n*\u6ce8\uff1a\u8981\u5728 `Authorization` \u5934\u90e8\u7684 `<AccessToken>` \u524d\u6dfb\u52a0 `Qiniu` \u548c\u534a\u89d2\u7a7a\u683c\u3002*\n\n\n\n### **\u54cd\u5e94**\n\n```\nHTTP\/1.1 200 OK\nContent-Length: 94\nConnection: keep-alive\nContent-Type: application\/json\nDate: Mon, 02 Jan 2006 15:04:05 GMT\nServer: nginx\nX-Reqid: jXwAAH8259lkr-UU\nBody:\n{\"id\":\"eyJ6b25lIjoiejAiLCJwYXJ0X2lkIjo2Mywib2Zmc2V0IjowfQ==\",\"wait\":-1}\n```\n\n\n\n## **\u67e5\u8be2\u4efb\u52a1:**\n\n## **\u8bf7\u6c42**\n\n### **\u8bf7\u6c42\u8bed\u6cd5**\n\n```\nGET \/sisyphus\/fetch?id=<ID> HTTP\/1.1\nHost: api-<Region>.qiniuapi.com\nAuthorization: Qiniu <AccessToken>\n`\n```\n\n### **\u8bf7\u6c42\u53c2\u6570**\n\n| \u53c2\u6570\u540d\u79f0 | \u5fc5\u586b | \u8bf4\u660e |\n| -------- | ---- | ----------- |\n| ID | \u662f | \u5f02\u6b65\u4efb\u52a1 ID |\n\n\n\n## **\u54cd\u5e94**\n\n### **\u54cd\u5e94\u5185\u5bb9**\n\n```\n{\"id\":\"<ID>\",\"wait\":<Wait>}\n```"}