Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
S
Sitemap Crawler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jan Klass
Sitemap Crawler
Commits
18721b8a
Commit
18721b8a
authored
Nov 13, 2018
by
Jan Klass
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix
parent
39e68569
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
crawl.jl
crawl.jl
+27
-19
No files found.
crawl.jl
View file @
18721b8a
...
...
@@ -10,30 +10,38 @@ struct CrawlData
CrawlData
()
=
new
(
Set
(),
Set
(),
Set
(),
Set
(),
Set
(),
Set
(),
Set
())
end
function
getprotocol
(
url
)
match
(
r
"^(?<protocol>[a-zA-Z0-9]+)?\:\/\/"
,
url
)[
:
protocol
]
end
function
handlehref_abs
(
data
::
CrawlData
,
base
,
url
,
href
,
href_protocol
;
forcehttps
=
false
)
if
href_protocol
==
"http"
&&
forcehttps
href_protocol
=
"https"
href_noprot
=
chop
(
href
;
head
=
length
(
href_protocol
),
tail
=
0
)
href
=
"https"
*
href_noprot
end
if
href_protocol
==
"http"
||
href_protocol
==
"https"
# Index urls that start with the base URL
if
startswith
(
href
,
base
)
push!
(
data
.
urls
,
href
)
@debug
"Match (absolute URL):
$
href"
else
@debug
"External URL:
$
href"
push!
(
data
.
urlsexternal
,
href
)
end
else
@debug
"Ignoring URL
$
href with ignored procotol
$
href_protocol"
end
end
function
handlehref
(
data
::
CrawlData
,
base
,
url
,
href
;
forcehttps
=
false
)
# Remove URL fragment (#)
href
=
match
(
r
"^(?<path>[^\#]*)"
,
href
)[
:
path
]
href_protocol
=
match
(
r
"^(?<protocol>[a-zA-Z0-9]+)?\:\/\/"
,
href
)[
:
protocol
]
href_protocol
=
getprotocol
(
href
)
if
href_protocol
!=
nothing
if
href_protocol
==
"http"
||
href_protocol
==
"https"
if
forcehttps
href_noprot
=
chop
(
href
;
head
=
length
(
href_protocol
),
tail
=
0
)
ismatch
=
startswith
(
href_noprot
,
base_noprot
)
else
ismatch
=
startswith
(
href
,
base
)
end
# Index urls that start with the base URL
if
ismatch
push!
(
data
.
urls
,
href
)
@debug
"Match (absolute URL):
$
href"
else
@debug
"External URL:
$
href"
push!
(
data
.
urlsexternal
,
href
)
end
else
@debug
"Ignoring URL
$
href with ignored procotol
$
href_protocol"
end
handlehref_abs
(
data
,
base
,
url
,
href
,
href_protocol
)
elseif
startswith
(
href
,
"/"
)
abshref
=
base
*
chop
(
href
;
head
=
1
,
tail
=
0
)
@debug
"Match (absolute path):
$
abshref"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment