mirror of
https://github.com/edoardottt/cariddi.git
synced 2026-09-22 17:44:58 +02:00
Add onXML event to catch sitemaps
This commit is contained in:
+26
-1
@@ -237,9 +237,34 @@ func Crawler(target string, txt string, html string, delayTime int, concurrency
|
||||
}
|
||||
})
|
||||
|
||||
// Create a callback on the XPath query searching for the URLs
|
||||
c.OnXML("//urlset/url/loc", func(e *colly.XMLElement) {
|
||||
link := e.Text
|
||||
output.EncapsulateCustomRed("XML URL", link)
|
||||
if len(link) != 0 {
|
||||
absoluteUrl := utils.AbsoluteURL(protocolTemp, targetTemp, e.Request.AbsoluteURL(link))
|
||||
// Visit link found on page
|
||||
// Only those links are visited which are in AllowedDomains
|
||||
if (!intensive && utils.SameDomain(protocolTemp+"://"+target, absoluteUrl)) ||
|
||||
(intensive && intensiveOk(targetTemp, absoluteUrl)) {
|
||||
if ignoreBool {
|
||||
if !IgnoreMatch(link, ignoreSlice) {
|
||||
FinalResults = append(FinalResults, absoluteUrl)
|
||||
c.Visit(absoluteUrl)
|
||||
}
|
||||
} else {
|
||||
FinalResults = append(FinalResults, absoluteUrl)
|
||||
c.Visit(absoluteUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
c.OnResponse(func(r *colly.Response) {
|
||||
|
||||
fmt.Println(r.Request.URL.String())
|
||||
if utils.SameDomain(protocolTemp+"://"+target, r.Request.URL.String()) {
|
||||
fmt.Println(r.Request.URL.String())
|
||||
}
|
||||
|
||||
lengthOk := len(string(r.Body)) > 10
|
||||
|
||||
|
||||
Reference in New Issue
Block a user