mirror of
https://github.com/intergalacticalvariable/reader.git
synced 2024-11-16 11:42:32 +08:00
manually set cookie
This commit is contained in:
parent
953429218a
commit
fc0023f381
|
@ -877,9 +877,15 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
|
|||
this.threadLocal.set('timeout', opts.timeout * 1000);
|
||||
}
|
||||
|
||||
const randomCookies = [
|
||||
{ name: 'session_id', value: Math.random().toString(36).substring(7), url: 'https://hargup-ripeharlequincephalopod.web.val.run/' },
|
||||
{ name: 'user_pref', value: 'dark_mode', url: 'https://hargup-ripeharlequincephalopod.web.val.run/' },
|
||||
{ name: 'visit_count', value: Math.floor(Math.random() * 10).toString(), url: 'https://hargup-ripeharlequincephalopod.web.val.run/' }
|
||||
];
|
||||
|
||||
const crawlOpts: ExtraScrappingOptions = {
|
||||
proxyUrl: opts.proxyUrl,
|
||||
cookies: opts.setCookies,
|
||||
cookies: randomCookies,
|
||||
favorScreenshot: ['screenshot', 'pageshot'].includes(opts.respondWith),
|
||||
removeSelector: opts.removeSelector,
|
||||
targetSelector: opts.targetSelector,
|
||||
|
|
|
@ -191,7 +191,7 @@ export class CrawlerOptions extends AutoCastable implements AutoCastableMetaClas
|
|||
static override from<T extends CrawlerOptions>(this: Constructor<T>, input: any, ...args: any[]): T {
|
||||
const instance = super.from(input, ...args) as T;
|
||||
const req = args[0] as Request | undefined;
|
||||
|
||||
|
||||
if (req) {
|
||||
console.log('Request headers:', req.headers);
|
||||
|
||||
|
|
|
@ -463,6 +463,7 @@ document.addEventListener('load', handlePageLoad);
|
|||
|
||||
async *scrap(parsedUrl: URL, options?: ScrappingOptions): AsyncGenerator<PageSnapshot | undefined> {
|
||||
// parsedUrl.search = '';
|
||||
console.log('Scraping options:', options);
|
||||
const url = parsedUrl.toString();
|
||||
|
||||
let snapshot: PageSnapshot | undefined;
|
||||
|
|
Loading…
Reference in New Issue
Block a user