Skip to content

Commit

Permalink
fix(forefront): try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangsx committed Jun 8, 2023
1 parent c3a51f7 commit 4a5a67b
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions model/forefront/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,22 @@ export class Forefrontnew extends Chat {
// get latest markdown id
let id = 4;
(async () => {
const selector = `div > .w-full:nth-child(${id}) > .flex > .flex > .post-markdown`;
await page.waitForSelector(selector);
const result = await page.$(selector)
const itl = setInterval(async () => {
const text: any = await result?.evaluate(el => {
return el.textContent;
});
if (text) {
pt.write("data", text);
}
}, 100)
if (!page) {
return;
}
let itl;
try {
const selector = `div > .w-full:nth-child(${id}) > .flex > .flex > .post-markdown`;
await page.waitForSelector(selector);
const result = await page.$(selector)
itl = setInterval(async () => {
const text: any = await result?.evaluate(el => {
return el.textContent;
});
if (text) {
pt.write("data", text);
}
}, 100)
if (!page) {
return;
}
await page.waitForSelector('.opacity-100 > .flex > .relative:nth-child(2) > .flex > .cursor-pointer', {timeout: 5 * 60 * 1000})
await page.click('.opacity-100 > .flex > .relative:nth-child(2) > .flex > .cursor-pointer')
//@ts-ignore
Expand All @@ -325,7 +326,9 @@ export class Forefrontnew extends Chat {
} else {
done(account);
}
clearInterval(itl);
if (itl) {
clearInterval(itl);
}
}
})().then();
return {text: pt.stream}
Expand Down

0 comments on commit 4a5a67b

Please sign in to comment.