Thread: Dumping NPC Pictures from wiki

Results 1 to 6 of 6
  1. #1 Dumping NPC Pictures from wiki 
    Banned

    Join Date
    Dec 2014
    Posts
    281
    Thanks given
    200
    Thanks received
    116
    Rep Power
    0
    I saw Free do this with his RSWP, which is worth buying btw because of how much better it is then this, but I decided to write something pretty quickly for the people who don't have $30 but still want some pictures. So basically this is how you would dump the pictures:

    This is not the best dumper out there, but it is the first tool I made for dumping anything from the wiki, so I don't think it's too bad. Enjoy
    I haven't managed to get the pictures to resize yet, but I will update the thread when I do, due to this it'll take a while to download all the pictures.

    You'll have to make a directory called Pictures in your Data folder.


    My NPCPictureDumper class that you'll need:
    Code:
    package com.util.tools.dumper;
    
    import java.io.BufferedWriter;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.util.Scanner;
    import javax.imageio.ImageIO;
    
    import java.awt.Image;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.net.URL;
    import com.Server;
    
    import com.Config;
    
    import com.fallenos.model.npcs.NPCHandler;
    import com.sun.xml.internal.bind.v2.runtime.Name;
    
    //Written by Rune-Server user, _lev518, used for dumping npc pictures from osrs wiki.
    
    public class NPCPictureDumper {
    
    	public static void main() throws FileNotFoundException {
    		int PICTURE_WIDTH = 32;
    		int PICTURE_HEIGHT = 32;
    		Scanner scanner2 = new Scanner(new FileReader("./src/com/util/tools/dumper/npcDump2.txt"));
    String npcName = null;
    		
    
    		for (int index = 0; index < 10000; index++) {
    			
    			/**
    			 * Fetches the item definition class
    			 */
    
    			
    			/**
    			 * If item definition is null we continue;
    			 */
    			if (scanner2.hasNextLine()) {
    				npcName = scanner2.nextLine().replaceAll(" ", "_");
    			}
    			if (npcName.contains("?")) {
    				continue;
    			}
    			/**
    			 * Represents the websites "lines" / "code lines"
    			 */
    			String line = "";
    
    			/**
    			 * Declare a String variable for the item name Replace any <space>
    			 * with '_'
    			 */
    
    			try {
    
    				/**
    				 * URL getter
    				 */
    				URL url = new URL("http://2007.runescape.wikia.com/wiki/"
    						+ npcName);
    				String[] justInCase = npcName.split("_");
    				/**
    				 * Application now connects to
    				 * http://2007.runescape.wikia.com/wiki/itemName
    				 */
    				url.openConnection();
    
    				/**
    				 * Scanner reads through the websites code
    				 */
    				Scanner scanner = new Scanner(new InputStreamReader(
    						url.openStream()));
    
    				/**
    				 * BufferedWriter write the data we need to a .txt file
    				 */
    				BufferedWriter writer = new BufferedWriter(new FileWriter(
    						"prices.txt", true));
    				
    				BufferedImage image = null;
    
    				while (scanner.hasNextLine()) {
    
    					/**
    					 * Everytime the while loop loops String line fetches a new
    					 * line of the website
    					 */
    					line = scanner.nextLine();
    					
    					if (line.contains("<meta property=\"og:image\" content=\"") && (line.contains(npcName +".png"))) {
    						line = line
    								.replace("\" />", "");
    						line = line.replace("<meta property=\"og:image\" content=\"", "");
    						
    						URL pictureUrl = new URL(line);
    						image = ImageIO.read(pictureUrl);
    						File varTmpDir = new File("./Data/pictures/"+npcName+".png");
    						boolean exists = varTmpDir.exists();
    						image.getScaledInstance(PICTURE_WIDTH, PICTURE_HEIGHT, Image.SCALE_SMOOTH);
    						if (!exists)
    						 ImageIO.write(image, "png",new File("./Data/pictures/"+npcName+".png"));
    						System.out.println(line);
    						writer.newLine();
    					}
    					else if (line.contains("<td colspan=\"2\" style=\"text-align: center;\"> <a href=\"") && (line.contains(npcName +".png"))) {
    						line = line
    								.replace("\" 	class=\"image image-thumbnail\" 	 	 	>", "");
    						line = line.replace("<td colspan=\"2\" style=\"text-align: center;\"> <a href=\"", "");
    						
    						URL pictureUrl = new URL(line);
    						image = ImageIO.read(pictureUrl);
    						File varTmpDir = new File("./Data/pictures/"+npcName+".png");
    						boolean exists = varTmpDir.exists();
    						image.getScaledInstance(PICTURE_WIDTH, PICTURE_HEIGHT, Image.SCALE_SMOOTH);
    						if (!exists)
    						 ImageIO.write(image, "png",new File("./Data/pictures/"+npcName+".png"));
    						System.out.println(line);
    						writer.newLine();
    					}
    				}
    				
    				writer.close();
    
    			} catch (IOException e) {
    
    			}
    		}
    
    	}
    }
    Post that anywhere you want, then you have to download this file:
    npcDump2.txt

    Then, find this in the dumper class:
    Code:
    Scanner scanner2 = new Scanner(new FileReader("./src/com/util/tools/dumper/npcDump2.txt"));
    and replace the destination with wherever you saved the file too.

    Then, in your start up method (usually in Server.java, call the dumper by adding this line:
    Code:
     
    //Don't forget to import!
    
    NPCPictureDumper.main();
    Result: Attached image

    Credits:
    Idiot Bird Used his GEDumper for help on how wiki dumping works.
    Free Inspired me to make this.
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Rune-Server Affiliate
    Genesis's Avatar
    Join Date
    Sep 2010
    Posts
    4,149
    Thanks given
    1,508
    Thanks received
    1,980
    Rep Power
    4944
    This has been known since 2011. Nothing new.

    https://www.rune-server.org/runescap...-grabbing.html
    Reply With Quote  
     

  4. #3  
    Banned

    Join Date
    Dec 2014
    Posts
    281
    Thanks given
    200
    Thanks received
    116
    Rep Power
    0
    Quote Originally Posted by Genesis View Post
    This has been known since 2011. Nothing new.

    https://www.rune-server.org/runescap...-grabbing.html
    Just trying to help some people out But thanks.
    Reply With Quote  
     

  5. #4  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    If you use Google inspection to find out where the actual image source is you'll get. http://vignette2.wikia.nocookie.net/2007scape/images/. Use this link instead so you can get the original image size and scale it to the size you want. You're grabbing the image that is scaled by retrieving the image from the actual wiki page.

    Also all you need to do is use a pattern

    Code:
      public static final Pattern npcImagePattern= Pattern.compile("(http://vignette2.wikia.nocookie.net/2007scape/images/[\\w+d+]+/[\\w+d+]+/[\\w+_]+_detail.png/revision/latest/)");
    no need to do this
    Code:
    					/**
    					 * Everytime the while loop loops String line fetches a new
    					 * line of the website
    					 */
    					line = scanner.nextLine();
    					
    					if (line.contains("<meta property=\"og:image\" content=\"") && (line.contains(npcName +".png"))) {
    						line = line
    								.replace("\" />", "");
    						line = line.replace("<meta property=\"og:image\" content=\"", "");
    						
    						URL pictureUrl = new URL(line);
    						image = ImageIO.read(pictureUrl);
    						File varTmpDir = new File("./Data/pictures/"+npcName+".png");
    						boolean exists = varTmpDir.exists();
    						image.getScaledInstance(PICTURE_WIDTH, PICTURE_HEIGHT, Image.SCALE_SMOOTH);
    						if (!exists)
    						 ImageIO.write(image, "png",new File("./Data/pictures/"+npcName+".png"));
    						System.out.println(line);
    						writer.newLine();
    					}
    					else if (line.contains("<td colspan=\"2\" style=\"text-align: center;\"> <a href=\"") && (line.contains(npcName +".png"))) {
    						line = line
    								.replace("\" 	class=\"image image-thumbnail\" 	 	 	>", "");
    						line = line.replace("<td colspan=\"2\" style=\"text-align: center;\"> <a href=\"", "");
    						
    						URL pictureUrl = new URL(line);
    						image = ImageIO.read(pictureUrl);
    						File varTmpDir = new File("./Data/pictures/"+npcName+".png");
    						boolean exists = varTmpDir.exists();
    						image.getScaledInstance(PICTURE_WIDTH, PICTURE_HEIGHT, Image.SCALE_SMOOTH);
    						if (!exists)
    						 ImageIO.write(image, "png",new File("./Data/pictures/"+npcName+".png"));
    						System.out.println(line);
    						writer.newLine();
    					}
    Attached image
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Registered Member Text's Avatar
    Join Date
    Nov 2012
    Posts
    302
    Thanks given
    61
    Thanks received
    27
    Rep Power
    21
    Thanks for this, I've written similar tools myself. Good release
    Attached image
    Reply With Quote  
     

  8. #6  
    Registered Member
    Join Date
    Apr 2016
    Posts
    148
    Thanks given
    46
    Thanks received
    30
    Rep Power
    19
    Quote Originally Posted by Genesis View Post
    This has been known since 2011. Nothing new.

    https://www.rune-server.org/runescap...-grabbing.html
    I know right, i hated it when he claimed to be a pioneer of dumping pics really grinds my gears

    Quote Originally Posted by _Lev518 View Post
    This is new and nobody knew about it before ever! im like the Neil Armstrong of dumping images from rswiki
    Reply With Quote  
     

  9. Thankful users:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 7
    Last Post: 07-07-2016, 04:59 PM
  2. Dumping item/npc definitions from site?
    By relex lawl in forum Help
    Replies: 3
    Last Post: 10-03-2012, 07:06 AM
  3. How to dump NPC variables from a client?
    By AceKingSuited in forum Requests
    Replies: 2
    Last Post: 04-13-2012, 05:00 AM
  4. Spiritual NPC'S (from Godwars Dungeon)
    By Zahhak in forum Models
    Replies: 8
    Last Post: 06-06-2009, 05:45 AM
  5. Dumping npc, combat level, Examine, for a list
    By william1434 in forum Tutorials
    Replies: 4
    Last Post: 03-30-2008, 09:26 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •