我有一个网络抓取应用程序,它可以简单地从两家大书店抓取书籍。这个想法是用户在 URL 中放置类别类型,例如/romances,/biographies。
控制器:_
package bookstore.scraper.controller;
imports...
import java.util.List;
import java.util.Map;
@RestController
public class BookController {
private final MostPreciseBookService mostPreciseBookService;
private final CategorizedBookService categorizedBookService;
private final BestSellersService bestSellersService;
@Autowired
public BookController(MostPreciseBookService bookOperationsService, CategorizedBookService categorizedBookService, BestSellersService bestSellersService) {
this.mostPreciseBookService = bookOperationsService;
this.categorizedBookService = categorizedBookService;
this.bestSellersService = bestSellersService;
}
.....
@GetMapping("/romances")
public Map<Bookstore, List<Book>> get15RomanticBooks() {
return categorizedBookService.get15BooksFromRomanceCategory();
}
@GetMapping("/biographies")
public Map<Bookstore, List<Book>> get15BiographiesBooks() {
return categorizedBookService.get15BooksFromBiographiesCategory();
}
@GetMapping("/guides")
public Map<Bookstore, List<Book>> get15GuidesBooks() {
return categorizedBookService.get15BooksFromGuidesCategory();
}
@GetMapping("/fantasy")
public Map<Bookstore, List<Book>> get15FantasyBooks() {
return categorizedBookService.get15BooksFromFantasyCategory();
}
@GetMapping("/crime")
public Map<Bookstore, List<Book>> get15CrimeBooks() {
return categorizedBookService.get15BooksFromCrimeCategory();
}
}
慕尼黑5688855
相关分类