Skip to content

Let's use AI to Earn!

feat: cookie加上

gaoSirb0e3f6bd1005
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index f60febd6..61c54720 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -6,7 +6,7 @@ import * as crypto from 'crypto';
import { v4 as uuidv4 } from 'uuid';
// @ts-ignore
import crc32 from 'crc32';
-import { getFileContent } from '../utils';
+import { CookieToString, getFileContent } from '../utils';
import {
DouyinLocationDataResponse,
DouyinTopicsSugResponse,
@@ -2003,6 +2003,7 @@ export class DouyinService {
keywords: string;
latitude: string;
longitude: string;
+ cookie: Electron.Cookie[];
}) {
return await requestNet<DouyinLocationDataResponse>({
url: `${this.loginUrl}aweme/v1/life/video_api/search/poi/?${jsonToQueryString(
@@ -2013,17 +2014,23 @@ export class DouyinService {
},
)}`,
method: 'GET',
+ headers: {
+ cookie: CookieToString(params.cookie),
+ },
});
}
// 获取热点数据
- async getHotspotData(params: { query: string }) {
+ async getHotspotData(params: { query: string; cookie: Electron.Cookie[]; }) {
return await requestNet<DouyinLocationDataResponse>({
url: `${this.loginUrl}aweme/v1/hotspot/search/?${jsonToQueryString({
...params,
count: 50,
})}`,
method: 'GET',
+ headers: {
+ cookie: CookieToString(params.cookie),
+ },
});
}
}
diff --git a/electron/plat/shipinhao/index.ts b/electron/plat/shipinhao/index.ts
index f4340c56..c1ae4cf7 100644
--- a/electron/plat/shipinhao/index.ts
+++ b/electron/plat/shipinhao/index.ts
@@ -2,7 +2,9 @@ import { screen, BrowserWindow, net, session } from 'electron';
import { CommonUtils } from '../../util/common';
import path from 'path';
import { FileUtils } from '../../util/file';
-import { getFileContent } from '../utils';
+import { CookieToString, getFileContent } from '../utils';
+import requestNet from '../requestNet';
+import { DouyinTopicsSugResponse } from '../douyin/douyin.type';
interface UserInfo {
authorId: string;
@@ -1303,6 +1305,23 @@ export class ShipinhaoService {
};
}
}
+
+ // 获取位置数据
+ async getLocation(params: {
+ keyword: string;
+ longitude: number;
+ latitude: number;
+ cookie: Electron.Cookie[];
+ }) {
+ return await requestNet<DouyinTopicsSugResponse>({
+ url: `https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/helper/helper_search_location`,
+ method: 'POST',
+ body: params,
+ headers: {
+ cookie: CookieToString(params.cookie),
+ },
+ });
+ }
}
// 导出服务实例
diff --git a/electron/plat/shipinhao/wxShp.type.ts b/electron/plat/shipinhao/wxShp.type.ts
new file mode 100644
index 00000000..9f6346b8
--- /dev/null
+++ b/electron/plat/shipinhao/wxShp.type.ts
@@ -0,0 +1,35 @@
+interface Location {
+ longitude: number;
+ latitude: number;
+ country: string;
+ countryCode: string;
+ province: string;
+ city: string;
+ region: string;
+ poiCheckSum: string;
+}
+
+interface POI {
+ uid: string;
+ name: string;
+ longitude: number;
+ latitude: number;
+ address: string;
+ province: string;
+ city: string;
+ region: string;
+ fullAddress: string;
+ source: number;
+ poiCheckSum: string;
+}
+
+export interface WeChatLocationData {
+ errCode: number;
+ errMsg: string;
+ data: {
+ list: POI[];
+ cookies: string;
+ address: Location;
+ continueFlag: number;
+ };
+}
\ No newline at end of file
diff --git a/electron/plat/utils/index.ts b/electron/plat/utils/index.ts
index 0308bc03..5d0a64c0 100644
--- a/electron/plat/utils/index.ts
+++ b/electron/plat/utils/index.ts
@@ -33,3 +33,7 @@ export async function getFileContent(filePath: string): Promise<Buffer> {
throw new Error(`读取文件失败: filePath`);
}
}
+
+export const CookieToString = (cookies: Electron.Cookie[]) => {
+ return cookies.map((cookie) => `${cookie.name}=${cookie.value}`).join('; ');
+};
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.ts
index 364bd7b5..8033525a 100644
--- a/electron/plat/xiaohongshu/index.ts
+++ b/electron/plat/xiaohongshu/index.ts
@@ -3,7 +3,7 @@ import * as crypto from 'crypto';
import sizeOf from 'image-size';
import { CommonUtils } from '../../util/common';
import { FileUtils } from '../../util/file';
-import { getFileContent } from '../utils';
+import { CookieToString, getFileContent } from '../utils';
import requestNet from '../requestNet';
import { IXHSLocationResponse, IXHSTopicsResponse } from './xiaohongshu.type';
@@ -1266,9 +1266,7 @@ export class XiaohongshuService {
url: `https://edith.xiaohongshu.com/web_api/sns/v1/search/topic`,
method: 'POST',
headers: {
- Cookie: cookies
- .map((cookie) => `${cookie.name}=${cookie.value}`)
- .join('; '),
+ cookie: CookieToString(cookies),
Referer: this.loginUrl,
origin: this.loginUrl,
},
@@ -1291,9 +1289,13 @@ export class XiaohongshuService {
size?: number;
source: string;
type: number;
+ cookies: Electron.Cookie[];
}) {
return await requestNet<IXHSLocationResponse>({
url: 'https://edith.xiaohongshu.com/web_api/sns/v1/local/poi/creator/search',
+ headers: {
+ cookie: CookieToString(params.cookies),
+ },
body: {
...params,
page: 1,