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:
Credits:
Idiot Bird Used his GEDumper for help on how wiki dumping works.
Free Inspired me to make this.