Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: [$50] Parse Webpage and dump data [RSPS-RELATED]

  1. #1
    Member
    Join Date
    Jul 2012
    Posts
    37
    Thanks
    0
    Thanked 1 Time in 1 Post

    Exclamation [$50] Parse Webpage and dump data [RSPS-RELATED]

    This is a RuneScape Private Server related task

    I have this code to start with:

    [SPOILER="Code"]
    package com.rs.utility.tools.dumpers;
     
    import java.io.IOException;
     
    import net.burtleburtle.cache.Cache;
    import net.burtleburtle.cache.loaders.NPCDefinitions;
     
    import com.rs.utility.Misc;
    import com.rs.utility.npc.NPCDrops;
    import com.rs.utility.tools.WebPage;
     
    /**
     * @author Tyluur <itstyluur@gmail.com>
     * @since 2012-09-15
     */
    public class RSWikiDropDumper {
     
    	public static void main(String[] args) throws IOException {
    		Cache.init();
    		for (int i = 0; i < Misc.getNPCDefinitionsSize(); i++) {
    			if (NPCDrops.getDrops(i) == null && NPCDefinitions.getNPCDefinitions(i).hasAttackOption()) {
    				dump(i);
    			}
    		}
    	}
     
    	private static void dump(int npcId) {
    		String URL = "http://runescape.wikia.com/wiki/" + NPCDefinitions.getNPCDefinitions(npcId).name.replaceAll(" ", "_");
    		System.out.println("Taking a dump for " + npcId);
    		try {
    			WebPage page = new WebPage(URL);
    			page.load();
    			for (String lines : page.getLines()) {
     
    			}
    		} catch (Throwable t) {
     
    		}
    		System.out.println("web page = " + URL);
    	}
     
    }
    [/spoiler]
    and the task of it is to dump all NPC (non-player-character) drops. It will be in this format:

    [SPOILER="code"]
    	public static void loadPackedNPCDrops() {
    		try {
    			RandomAccessFile in = new RandomAccessFile(PACKED_PATH, "r");
    			FileChannel channel = in.getChannel();
    			ByteBuffer buffer = channel.map(MapMode.READ_ONLY, 0, channel.size());
    			int dropMapSize = buffer.getShort();
    			ArrayList<Drop> drops = null;
    			for (int i = 0; i < dropMapSize; i++) {
    				int npcId = buffer.getShort();
    				short dropAmount = buffer.getShort();
    				drops = new ArrayList<Drop>(dropAmount);
    				for (int x = 0; x < dropAmount; x++)
    					drops.add(new Drop(buffer.getShort(), buffer.getInt(), buffer.getInt(), getChanceType(buffer.getInt())));
    				npcDrops.put(npcId, drops);
    			}
    			loadCustomDrops();
    			channel.close();
    			in.close();
    		} catch (Throwable e) {
    			e.printStackTrace();
    		}
    	}
     
    	/**
    	 * @return
    	 */
    	private static ChanceType getChanceType(int ordinal) {
    		switch (ordinal) {
    		case 0:
    			return ChanceType.ALWAYS;
    		case 1:
    			return ChanceType.COMMON;
    		case 2:
    			return ChanceType.UNCOMMON;
    		case 3:
    			return ChanceType.RARE;
    		case 4:
    			return ChanceType.VERY_RARE;
    		}
    		return ChanceType.VERY_RARE;
    	}
    [/spoiler]

    I need the parsing of the Drops to be completed in this format:
    npcId quantity itemId minimumamount maxamount rarity(saved based on ordinal in enum)
    This is the source code for the libraries required to run this script.

    This is an example of one of the lines in the dump of what I have so far from unpacking a buffered file which was released with all of this information, but a minimal dump:

    1 31 2485 1 1 3

    NOTE: Packaging will be different, eclipse tool to organize imports will do this easily for you.

    If you can understand this without any previous RuneScape Private Server knowledge, add my msn: itstyluur@gmail.com

    Money will be sent after job is completed and proof is shown via images/teamviewer.


  2. #2
    Member
    Join Date
    Sep 2011
    Posts
    40
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: [$50] Parse Webpage and dump data [RSPS-RELATED]

    I don't see what is wrong.

Similar Threads

  1. Please help me analyze this java core dump on AIX
    By acejun01 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 12th, 2014, 05:21 AM
  2. This program cannot display the webpage
    By Probal14 in forum Java IDEs
    Replies: 1
    Last Post: January 5th, 2012, 11:15 PM
  3. error related arrays outputting wront data...
    By semicolon in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 1st, 2011, 09:34 AM
  4. Creating a binary dump of a file
    By NRDargie in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: July 20th, 2010, 05:24 PM
  5. Login form on webpage
    By rosebabz in forum JDBC & Databases
    Replies: 0
    Last Post: January 14th, 2010, 10:34 AM