Jump to content

Question

Recommended Posts

  • 0
Posted (edited)
       int votes = -1;
        try
        {
            URL url = new URL(Config.VOTES_SITE_TOPZONE_URL);
            URLConnection con = url.openConnection();
            con.setConnectTimeout(5000);
            con.setReadTimeout(5000);
            con.addRequestProperty("User-Agent", "L2TopZone");
            InputStream is = con.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader in = new BufferedReader(isr);
            String inputLine;
            while ((inputLine = in.readLine()) != null)
            {
                if (inputLine.contains("Votes:"))
                {
                    votes = Integer.valueOf(inputLine.split("<br>")[1].replace("</div>", ""));
                    break;
                }
            }
            in.close();
            isr.close();
            is.close();
        }
        catch (Exception e)
        {
            _log.info("[AutoVoteReward] Server TOPZONE is offline or something is wrong in link");
        }
        return votes;

The link should be like:

http://l2topzone.com/totalvotes.php?id=9752

You get only the server ID.

http://l2topzone.com/lineage/server-info/9752/l2blacksails

Edited by 'Baggos'

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...