yujian
2019-09-25 fb5823c1408e5c06592350722f6b9e117580ca9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.yeshi.fanli.util;
 
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
 
public class DouYinUtil {
 
    public static String parseDouYinGoods(String url) {
        HttpClient httpClient = new HttpClient();
        GetMethod gm = new GetMethod(url);
        try {
            httpClient.executeMethod(gm);
            String finalUrl = gm.getURI().toString();
            if (finalUrl.startsWith("https://s.click.taobao.com")) {
                Document doc = Jsoup.parse(gm.getResponseBodyAsString());
            
                Elements els = doc.getElementsByTag("meta");
                for (int i = 0; i < els.size(); i++) {
                    if (els.get(i).toString().contains("URL=")) {
//                        System.out.println(els.get(i)..toString());
                    }
                    System.out.println(els.get(i).attr("URL"));
                }
            }
 
        } catch (Exception e) {
        }
        return null;
    }
 
}