这边顺手记录一个 搜索 依赖的网站

maven

首先导入

<dependency>
  <groupId>org.jsoup</groupId>
  <artifactId>jsoup</artifactId>
  <version>1.15.3</version>
</dependency>
class Likefr implements Runnable {
    private final String url = "http://lab.liumingye.cn/";
    private static String title;
    private static String titleUrl;
    private static String name;
    private static  String img;
    Document document = null;

    @Override
    public void run() {

        try {
            document = Jsoup.connect(url)
                    // .timeout(5000)
                    .get();
        } catch (IOException e) {
            // e.printStackTrace();
            //System.out.println("超时");
        }

        Elements elements = document.select("div.stui-vodlist__box.stui-vodlist__bg");
       // System.out.println(elements);

       String regEx = "[^0-9]";
        if (!elements.isEmpty()) {
            for (Element tittle : elements) {
                Element first = tittle.select("a[href]").first();

               if (first != null) {
                    title = first.attr("title");
                   img = first.attr("data-original");

                    titleUrl = first.attr("href");
                    System.out.println("标题:" + title);
                   System.out.println("图片:"+img);
                    System.out.println("具体地址:" + url + titleUrl);

                    Pattern p = Pattern.compile(regEx);
                    Matcher m = p.matcher(titleUrl + "");
                    System.out.println("id:======>" + m.replaceAll("").trim()+"\n");
                }
            }
        }
    }
}
最后修改:2022 年 12 月 28 日
如果觉得我的文章对你有用,请随意赞赏