You need to sign in or sign up before continuing.
Commit eb385cb2 by 马黎滨

抖音链接获取

parent d0bc150f
......@@ -76,4 +76,33 @@ public class DouyinHotSearchCrawler {
return list;
}
/**
* 获取抖音url
* @param url
* @return
*/
public static String getDouyinUrl(String url){
String resultUrl = null;
String htmlBody = null;
Request request = RequestUtils.wrapGet(url);
try(Response response = httpBoot.syncCall(request, ProxyHolder.NAT_HEAVY_PROXY)) {
htmlBody = response.body().string();
}catch (IOException e) {
log.debug("获取抖音热搜榜链接时出现问题:{}", e);
}
if (StringUtils.isNotBlank(htmlBody) && htmlBody.contains("aweme_list")){
JSONArray jsonArray = JSONObject.parseObject(htmlBody).getJSONArray("aweme_list");
for(int i=0; i<jsonArray.size(); i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
if(jsonObject.containsKey("share_url")){
resultUrl = jsonObject.getString("share_url");
if(!"".equals(resultUrl)) {
return resultUrl;
}
}
}
}
return resultUrl;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment