点击网址后,我通过html响应获取 Google趋势数据。我设法通过Jsoup库解析该响应。我得到的数据只有3-4次。之后它开始给出Status-203错误。每天我运行此代码3-4次后我得到了这个异常。请帮帮我,我现在该怎么办? 我的代码是 -
public class HTMLParser {
private static HashMap<String, HashMap<String, String>> hostcokkies = new HashMap<String, HashMap<String,String>>();
public static ArrayList<HotTrends> getYouTubeTrendings()
{
Document document;
ArrayList<HotTrends> list = new ArrayList<HotTrends>();
HotTrends trends = null;
try {
document = Jsoup.connect("http://www.google.com/trends/fetchComponent?geo=IN&date=today+12-m&gprop=youtube&cmpt=q&cid=TOP_QUERIES_0_0").get();
Elements links = document.select("a[href]");
for(Element link : links){
trends = new HotTrends();
trends.setWord(link.text());
list.add(trends);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return list;
}
public static void main(String args[])
{
ArrayList<HotTrends> hotTrends = new ArrayList<HotTrends>();
hotTrends = HTMLParser.getYouTubeTrendings();
for(HotTrends trends : hotTrends)
{
System.out.println(trends.getWord());
}
}
}
答案 0 :(得分:1)
我遇到同样的问题,只需自己更改您的IP地址或使用程序(我使用Hotspot Shield http://www.hotspotshield.com/)它对我有效