We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原因:微博的json格式改了 解决办法 在WeiboUtils类中的getImgURL方法改成: private static int getImgURL(String containerid,int page, List urls) throws ParseException, IOException{ String url = "https://m.weibo.cn/api/container/getIndex?count=25&page="+page+"&containerid="+containerid; HttpClient httpClient = getHttpClient(); HttpGet get = new HttpGet(url); get.setHeader("User-Agent", USER_AGENT); HttpResponse response = httpClient.execute(get); String ret = EntityUtils.toString(response.getEntity(), "utf-8"); JsonObject root = new JsonParser().parse(ret).getAsJsonObject(); JsonObject asJsonObject = root.getAsJsonObject("data"); JsonArray array = asJsonObject.getAsJsonArray("cards"); System.out.println(array); for(int i=0;i<array.size();i++){ JsonObject mblog = array.get(i).getAsJsonObject().getAsJsonObject("mblog"); if(mblog!=null){ JsonArray pics = mblog.getAsJsonArray("pics"); if(pics!=null){ for(int j=0;j<pics.size();j++){ JsonObject o = pics.get(j).getAsJsonObject(); JsonObject large = o.getAsJsonObject("large"); if(large!=null){ urls.add(large.get("url").getAsString()); } } } } } return array.size(); }
保存后运行即可
The text was updated successfully, but these errors were encountered:
感谢,已经修改
Sorry, something went wrong.
No branches or pull requests
原因:微博的json格式改了
解决办法 在WeiboUtils类中的getImgURL方法改成:
private static int getImgURL(String containerid,int page, List urls) throws ParseException, IOException{
String url = "https://m.weibo.cn/api/container/getIndex?count=25&page="+page+"&containerid="+containerid;
HttpClient httpClient = getHttpClient();
HttpGet get = new HttpGet(url);
get.setHeader("User-Agent", USER_AGENT);
HttpResponse response = httpClient.execute(get);
String ret = EntityUtils.toString(response.getEntity(), "utf-8");
JsonObject root = new JsonParser().parse(ret).getAsJsonObject();
JsonObject asJsonObject = root.getAsJsonObject("data");
JsonArray array = asJsonObject.getAsJsonArray("cards");
System.out.println(array);
for(int i=0;i<array.size();i++){
JsonObject mblog = array.get(i).getAsJsonObject().getAsJsonObject("mblog");
if(mblog!=null){
JsonArray pics = mblog.getAsJsonArray("pics");
if(pics!=null){
for(int j=0;j<pics.size();j++){
JsonObject o = pics.get(j).getAsJsonObject();
JsonObject large = o.getAsJsonObject("large");
if(large!=null){
urls.add(large.get("url").getAsString());
}
}
}
}
}
return array.size();
}
保存后运行即可
The text was updated successfully, but these errors were encountered: