Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Gpt Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SwiftChat
Gpt Crawler
Commits
567ab0b0
Commit
567ab0b0
authored
3 months ago
by
Zephyr
Browse files
Options
Downloads
Patches
Plain Diff
fix: correctly set cookies
parent
2ca876e6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core.ts
+11
-8
11 additions, 8 deletions
src/core.ts
with
11 additions
and
8 deletions
src/core.ts
+
11
−
8
View file @
567ab0b0
...
...
@@ -104,13 +104,11 @@ export async function crawl(config: Config) {
// Uncomment this option to see the browser window.
// headless: false,
preNavigationHooks
:
[
// Abort requests for certain resource types
async
({
request
,
page
,
log
})
=>
{
// If there are no resource exclusions, return
const
RESOURCE_EXCLUSTIONS
=
config
.
resourceExclusions
??
[];
if
(
RESOURCE_EXCLUSTIONS
.
length
===
0
)
{
return
;
}
// Abort requests for certain resource types and add cookies
async
(
crawlingContext
,
_gotoOptions
)
=>
{
const
{
request
,
page
,
log
}
=
crawlingContext
;
// Add cookies to the page
// Because the crawler has not yet navigated to the page, so the loadedUrl is always undefined. Use the request url instead.
if
(
config
.
cookie
)
{
const
cookies
=
(
Array
.
isArray
(
config
.
cookie
)
?
config
.
cookie
:
[
config
.
cookie
]
...
...
@@ -118,11 +116,16 @@ export async function crawl(config: Config) {
return
{
name
:
cookie
.
name
,
value
:
cookie
.
value
,
url
:
request
.
loadedU
rl
,
url
:
request
.
u
rl
,
};
});
await
page
.
context
().
addCookies
(
cookies
);
}
const
RESOURCE_EXCLUSTIONS
=
config
.
resourceExclusions
??
[];
// If there are no resource exclusions, return
if
(
RESOURCE_EXCLUSTIONS
.
length
===
0
)
{
return
;
}
await
page
.
route
(
`**\/*.{
${
RESOURCE_EXCLUSTIONS
.
join
()}
}`
,
(
route
)
=>
route
.
abort
(
"
aborted
"
),
...
...
This diff is collapsed.
Click to expand it.
GitSwiftDev
@GitSwiftDev
mentioned in commit
25ab4f12
·
2 months ago
mentioned in commit
25ab4f12
mentioned in commit 25ab4f12486dd54a49e913449b63c58792bd6faa
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment