Skip to content

Commit

Permalink
Raw source code output
Browse files Browse the repository at this point in the history
  • Loading branch information
CybearTony committed Jun 17, 2021
1 parent 2620182 commit 028c070
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Flags:
-v, --verbose Turn on verbose
-l, --length Turn on length
-L, --filter-length Turn on length filter
-R, --raw Turn on raw
-q, --quiet Suppress all the output and only show URL
--no-redirect Disable redirect
--version Check version
Expand Down
23 changes: 23 additions & 0 deletions core/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Crawler struct {
Quiet bool
JsonOutput bool
length bool
raw bool

filterLength_slice []int

Expand Down Expand Up @@ -85,6 +86,7 @@ func NewCrawler(site *url.URL, cmd *cobra.Command) *Crawler {
delay, _ := cmd.Flags().GetInt("delay")
randomDelay, _ := cmd.Flags().GetInt("random-delay")
length, _ := cmd.Flags().GetBool("length")
raw, _ := cmd.Flags().GetBool("raw")

c := colly.NewCollector(
colly.Async(true),
Expand Down Expand Up @@ -281,6 +283,7 @@ func NewCrawler(site *url.URL, cmd *cobra.Command) *Crawler {
Input: site.String(),
JsonOutput: jsonOutput,
length: length,
raw: raw,
domain: domain,
Output: output,
urlSet: stringset.NewStringFilter(),
Expand Down Expand Up @@ -443,6 +446,16 @@ func (crawler *Crawler) Start(linkfinder bool) {
if crawler.Output != nil {
crawler.Output.WriteToFile(outputFormat)
}

if crawler.raw {
outputFormat := fmt.Sprintf("[Raw] - \n%s\n", respStr) //PRINTCLEAN RAW for link visited only
if !crawler.Quiet {
fmt.Println(outputFormat)
}
if crawler.Output != nil {
crawler.Output.WriteToFile(outputFormat)
}
}
}
})

Expand Down Expand Up @@ -644,6 +657,16 @@ func (crawler *Crawler) setupLinkFinder() {
}
}
}

if crawler.raw {
outputFormat := fmt.Sprintf("[Raw] - \n%s\n", respStr) //PRINTCLEAN RAW for link visited only
if !crawler.Quiet {
fmt.Println(outputFormat)
}
if crawler.Output != nil {
crawler.Output.WriteToFile(outputFormat)
}
}
}
})
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func main() {
commands.Flags().BoolP("no-redirect", "", false, "Disable redirect")
commands.Flags().BoolP("version", "", false, "Check version")
commands.Flags().BoolP("length", "l", false, "Turn on length")
commands.Flags().BoolP("raw", "R", false, "Enable raw output")


commands.Flags().SortFlags = false
Expand Down

0 comments on commit 028c070

Please sign in to comment.