CrawlURLs crawls the specified URLs on the specified Crawler. It returns the Task ID if successful.
( crawlerID string, URLs []string, save, saveSpecified bool, )
| 285 | // CrawlURLs crawls the specified URLs on the specified Crawler. |
| 286 | // It returns the Task ID if successful. |
| 287 | func (c *Client) CrawlURLs( |
| 288 | crawlerID string, |
| 289 | URLs []string, |
| 290 | save, saveSpecified bool, |
| 291 | ) (string, error) { |
| 292 | var res TaskIDResponse |
| 293 | path := fmt.Sprintf("crawlers/%s/urls/crawl", crawlerID) |
| 294 | |
| 295 | var body interface{} |
| 296 | if saveSpecified { |
| 297 | body = struct { |
| 298 | URLs []string `json:"urls"` |
| 299 | Save bool `json:"save"` |
| 300 | }{URLs, save} |
| 301 | } else { |
| 302 | body = struct { |
| 303 | URL []string `json:"urls"` |
| 304 | }{URLs} |
| 305 | } |
| 306 | |
| 307 | err := c.request(&res, http.MethodPost, path, body, nil) |
| 308 | if err != nil { |
| 309 | return "", err |
| 310 | } |
| 311 | |
| 312 | return res.TaskID, nil |
| 313 | } |
| 314 | |
| 315 | // Test tests an URL on the specified Crawler. |
| 316 | func (c *Client) Test(crawlerID, URL string, config *Config) (*TestResponse, error) { |