@saber2pr/baidu-chart-api
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -21,2 +21,3 @@ export declare class BaiduChart { | ||
search(keyword: string): Promise<{ | ||
word: string; | ||
startDate: string; | ||
@@ -23,0 +24,0 @@ endDate: string; |
@@ -45,3 +45,3 @@ "use strict"; | ||
* @Last Modified by: saber2pr | ||
* @Last Modified time: 2019-06-21 21:33:02 | ||
* @Last Modified time: 2019-06-22 09:58:46 | ||
*/ | ||
@@ -100,3 +100,3 @@ var axios_1 = __importDefault(require("axios")); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, uniqid, _b, startDate, endDate, data, ptbk; | ||
var _a, uniqid, _b, word, startDate, endDate, data, ptbk; | ||
return __generator(this, function (_c) { | ||
@@ -111,3 +111,3 @@ switch (_c.label) { | ||
case 1: | ||
_a = (_c.sent()).data.data, uniqid = _a.uniqid, _b = _a.all, startDate = _b.startDate, endDate = _b.endDate, data = _b.data; | ||
_a = (_c.sent()).data.data, uniqid = _a.uniqid, _b = _a.all, word = _b.word, startDate = _b.startDate, endDate = _b.endDate, data = _b.data; | ||
return [4 /*yield*/, this.getPTBK(uniqid)]; | ||
@@ -117,2 +117,3 @@ case 2: | ||
return [2 /*return*/, { | ||
word: word, | ||
startDate: startDate, | ||
@@ -119,0 +120,0 @@ endDate: endDate, |
@@ -1,3 +0,2 @@ | ||
export declare const zip: (a: any[], b: any[]) => any; | ||
export declare const createPtbkMap: (ptbk: string) => any; | ||
export declare const transformDataFromPtbk: (ptbk: string, data: string) => string; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,10 +7,5 @@ /* | ||
* @Last Modified by: saber2pr | ||
* @Last Modified time: 2019-06-21 21:00:24 | ||
* @Last Modified time: 2019-06-22 10:00:47 | ||
*/ | ||
exports.zip = function (a, b) { | ||
return a.reduce(function (receiver, x, i) { | ||
var _a; | ||
return (__assign({}, receiver, (_a = {}, _a[x] = b[i], _a))); | ||
}, {}); | ||
}; | ||
var list_1 = require("@saber2pr/fp/lib/list"); | ||
exports.createPtbkMap = function (ptbk) { | ||
@@ -31,3 +15,3 @@ var m = ptbk.length / 2; | ||
var value = ptbk.slice(m).split(''); | ||
return exports.zip(key, value); | ||
return list_1.zip(key)(value); | ||
}; | ||
@@ -34,0 +18,0 @@ exports.transformDataFromPtbk = function (ptbk, data) { |
{ | ||
"name": "@saber2pr/baidu-chart-api", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "> 百度指数数据解析", | ||
@@ -13,9 +13,18 @@ "repository": { | ||
"lib/core/*", | ||
"lib/index.*" | ||
"lib/index.*", | ||
"lib/app.*" | ||
], | ||
"bin": { | ||
"baiduChart": "./lib/app.js" | ||
}, | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"test": "node ./lib/test/test.js", | ||
"start": "tsc --watch" | ||
"start": "tsc --watch", | ||
"app": "node ./lib/app.js" | ||
}, | ||
"keywords": [ | ||
"cli", | ||
"baidu" | ||
], | ||
"devDependencies": { | ||
@@ -25,4 +34,6 @@ "typescript": "^3.4.3" | ||
"dependencies": { | ||
"@saber2pr/fp": "0.0.5", | ||
"@saber2pr/node": "^0.2.4", | ||
"axios": "^0.19.0" | ||
} | ||
} | ||
} |
@@ -5,10 +5,22 @@ # @saber2pr/baidu-chart-api | ||
> 送给 b 站的小伙伴 qwq | ||
# 使用方法 | ||
1. 确保电脑安装 node.js | ||
2. 打开 cmd(或终端),执行以下命令安装 app | ||
```bash | ||
# from npm | ||
npm install @saber2pr/baidu-chart-api | ||
npm install @saber2pr/baidu-chart-api -g | ||
``` | ||
# from github | ||
git clone https://github.com/Saber2pr/baidu-chart-api.git | ||
3. 命令行执行 | ||
```bash | ||
baiduChart | ||
``` | ||
> 命令行输入 baiduChart 回车,然后根据提示就可以了 | ||
# API | ||
@@ -22,2 +34,8 @@ | ||
- cookie 需要抓包获得。([以`BAIDUID`开头的值就可以了, 示例>>](https://github.com/Saber2pr/baidu-chart-api/blob/master/src/test/test.ts#L10)) | ||
> document.cookie 拿到的值不行!虽然大部分 cookie 都是 httponly=false 的,但是也有个别有安全策略。所以不如直接抓包来的快。 | ||
> 其实 cookie 是可以服务端模拟登录拿到的,但是由于百度的身份认证加密过于复杂,up 我只能手动复制 cookie 了 T_T | ||
--- | ||
@@ -24,0 +42,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15421
300
65
3
+ Added@saber2pr/fp@0.0.5
+ Added@saber2pr/node@^0.2.4
+ Added@saber2pr/fp@0.0.5(transitive)
+ Added@saber2pr/node@0.2.9(transitive)
+ Added@types/node@10.17.60(transitive)