import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.io.IOException;
public class WebCrawler {
// Function to send HTTP request and get webpage content
public static String getWebPageContent(String url) throws IOException {
Document doc = Jsoup.connect(url).get();
return doc.html();
}
public static void main(String[] args) {
String url = "https://www.amazon.com/-/zh/dp/B0CC5HY7FW/ref=sr_1_3?_encoding=UTF8&content-id=amzn1.sym.44da4965-9668-4613-bec2-a3a75f0c2ad4&dib=eyJ2IjoiMSJ9.TqZtUw0ORg_Kb3n5ChdlL2h7w44tvgSgP33_D12tIprwVNMJoOVi8QPQe-Ij_WyXZZsITqjUAVqcFPSaGDUhNkNPNIiPQ6lPkKuabSkZuNAyV-h3AvA0xrfs1-aMp1ZhSISrLHvCDFnas0SGfu4QT3bS-Zp0o9tKZ3dsGomeUkU0B4xIgUQQm46v5GIknSinM6x-F-vfX3JvxrSFbDj3gTaW3u-dpqBEYeGcsmAmojWyEm3Z6VR-x4a9j8KhJEH0RnxpVSRma2hCyFrLuNoOEMKIyjdfhy_w4f8d7y9Sss8.zBJmE1hOMbLRM-TQKXtC8TNq_bFGhBqfwmCLizSrOO4&dib_tag=se&keywords=toys&pd_rd_r=e087e5a5-fcc4-4fa6-b531-b6380d98f2bd&pd_rd_w=jdgT4&pd_rd_wg=ky51D&pf_rd_p=44da4965-9668-4613-bec2-a3a75f0c2ad4&pf_rd_r=7H9W28AWHDWEDY311T0J&qid=1716633206&refinements=p_36%3A-2500&sr=8-3";
try {
// Send HTTP request and get webpage content
String htmlContent = getWebPageContent(url);
// Parse HTML content
Document doc = Jsoup.parse(htmlContent);
String xpathExpression = "//span[@class=\"a-size-medium a-color-base _p13n-desktop-sims-fbt_fbt-desktop_total-amount__wLVdU\"]";
Element priceElement = doc.selectFirst(xpathExpression);
// Extract price text
String priceText = priceElement.text();
System.out.println("Price: " + priceText);
} catch (IOException e) {
e.printStackTrace();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 3 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/b46a9763b4054a4e90ef787a9110240e_qq_57489104.jpg!1)
优秀码农哥
- 粉丝: 190
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)