forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(route): picnob * fix(route): picnob. Use one browser session to do all http requests. * fix(route): picnob. Use puppeteer as a fallback option when a normal request returns a 403 error. * fix(route): picnob. Block unnecessary requests when using puppeteer. * fix(route): picnob. Adaptation of JSON responses when using puppeteer for http requests. * Update lib/v2/picnob/user.js ---------
- Loading branch information
1 parent
39cf927
commit 3f7c8d9
Showing
4 changed files
with
102 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
'/user/:id': ['TonyRL'], | ||
'/user/:id': ['TonyRL', 'micheal-death'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const puppeteerGet = async (url, browser) => { | ||
let data; | ||
const page = await browser.newPage(); | ||
await page.setRequestInterception(true); | ||
page.on('request', (request) => { | ||
request.resourceType() === 'document' ? request.continue() : request.abort(); | ||
}); | ||
page.on('response', async (response) => { | ||
if (response.request().url().includes('/api/posts')) { | ||
data = await response.json(); | ||
} else { | ||
data = await response.text(); | ||
} | ||
}); | ||
await page.goto(url, { | ||
waitUntil: 'domcontentloaded', | ||
}); | ||
await page.close(); | ||
return data; | ||
}; | ||
|
||
module.exports = { | ||
puppeteerGet, | ||
}; |