CrawlerController.java
804 Bytes
package com.mass.controller;
import com.mass.service.PoliceNewsCrawlerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/crawler")
public class CrawlerController {
@Autowired
private PoliceNewsCrawlerService crawlerService;
@GetMapping("/page/{pageNum}")
public String crawlPage(@PathVariable int pageNum) {
return crawlerService.crawlNewsByPage(pageNum);
}
@GetMapping("/all")
public String crawlAll() {
return crawlerService.crawlAllNews();
}
}