Browse Source

cookies in profile fixed

master
filesite 1 year ago
parent
commit
8c960a8c3d
  1. 2
      bot/Douyin.mjs
  2. 1
      bot/HeroBot.mjs
  3. 6
      test/douyin_test.mjs

2
bot/Douyin.mjs

@ -19,7 +19,7 @@ class Douyin extends HeroBot { @@ -19,7 +19,7 @@ class Douyin extends HeroBot {
const profile = await this.init('douyin');
if (profile) {
options.userProfile = this.fixCookies(profile);
options.userProfile = profile;
}
const hero = new Hero(options);

1
bot/HeroBot.mjs

@ -75,6 +75,7 @@ class HeroBot { @@ -75,6 +75,7 @@ class HeroBot {
try {
//保存profile
const profilePath = path.resolve('../tmp/', `profile_${botName}.json`);
profile = this.fixCookies(profile);
fs.writeFileSync(profilePath, JSON.stringify(profile, null, 2));
}catch(error) {
console.error("Error got when save profile of %s, error detail:\n%s", botName, error);

6
test/douyin_test.mjs

@ -1,14 +1,16 @@ @@ -1,14 +1,16 @@
import Hero from '@ulixee/hero';
(async () => {
const hero = new Hero({ connectionToCore: 'ws://192.168.3.13:1818' });
const hero = new Hero({
connectionToCore: 'ws://192.168.3.13:1818',
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
});
const url = 'https://v.douyin.com/iJr1NsJJ/';
console.log("请求 %s 中。。。", url);
await hero.goto(url, {
timeoutMs: 10000,
referrer: 'https://wechat.com',
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
});
//const title = await hero.document.title;

Loading…
Cancel
Save