我现在有一个很大的问题,我希望有人知道修复。
在我的服务器上,我使用此代码检查网站上的投票计数:
@Override
public int getVoteCount()
{
int votes = 0;
try
{
URL oracle = new URL(getLinkToCheck());
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
if (inputLine.contains("<div class='list_8' style=\"font-weight: bold\">"))
{
String line = inputLine.split("<div class='list_8' style=\"font-weight: bold\">")[1].split("</div>")[0].trim().replaceAll(" ", "");
votes = Integer.parseInt(line);
if (VoteManager.VOTE_DEBUG)
{
System.out.println("VoteManager [" + getClass().getSimpleName() + "]: Votes count: [" + votes + "]");
}
return votes;
}
}
in.close();
}
catch (Exception e)
{
System.out.println(e);
}
return votes;
}