forked from go/golangs_learn
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							23 lines
						
					
					
						
							407 B
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							23 lines
						
					
					
						
							407 B
						
					
					
				| package main | |
| 
 | |
| import ( | |
| 	"fmt" | |
| 	"github.com/gocolly/colly" | |
| ) | |
| 
 | |
| func main() { | |
| 	// 使用默认设置创建收集器: | |
| 	c := colly.NewCollector() | |
| 
 | |
| 	// Find and visit all links | |
| 	c.OnHTML("a[href]", func(e *colly.HTMLElement) { | |
| 		e.Request.Visit(e.Attr("href")) | |
| 	}) | |
| 
 | |
| 	c.OnRequest(func(r *colly.Request) { | |
| 		fmt.Println("Visiting", r.URL) | |
| 		fmt.Println("HTML", r.Body) | |
| 	}) | |
| 
 | |
| 	c.Visit("https://www.viviman.top/") | |
| }
 | |
| 
 |