import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import java.io.IOException; public abstract class AbstractCrawlStrategy implements CrawlStrategy { @Override public Document fetchDocument(String url) throws IOException { return Jsoup.connect(url) .timeout(15000) .userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36") .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8") .header("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8") .get(); } protected double parsePrice(String text) { try { String cleanText = text.replaceAll("[^0-9.]", ""); if (cleanText.isEmpty()) return 0.0; return Double.parseDouble(cleanText); } catch (Exception e) { return 0.0; } } protected double parseDiscount(double price, double originalPrice) { if (originalPrice <= 0) return 10.0; return Math.round((price / originalPrice) * 100) / 10.0; } }