C# Imvu HP Image Ripper [Updated 9-23-2012]

DataMine
by DataMine · 7 posts
12 years ago in .Net (C#, VB, etc)
Posted 12 years ago · Author
This is a console app I wrote to rip stickers and display pictures from homepages. It accepts a single homepage or a list of multiple homepages. It will iterate through each homepage you provide and download every image that matches an Imvu sticker file and/or a display picture.

You can use this other tool I made to build lists of homepages: https://www.imvumafias.org/community/viewtop ... 109&t=8537

The sticker grabber doesn't support ap homepages yet but I plan on adding that ability as soon as I can.

See my Free IDES thread if you need an IDE to build this program with: viewtopic.php?f=109&t=8525

You need the HtmlAgilityPack library to use this, you can grab it at the bottom of this post.

Image

[code=csharp file=Untitled.txt]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using HtmlAgilityPack;

namespace IMVU_Hp_Image_Ripper
{
class Program
{
private static string input = "";
private static string imgtype = "";
private static string rtrn = "";
private static bool file = false;
private static bool stickers = false;
private static bool displaypic = false;

static void Main(string[] args)
{
menu();
}

private static void menu()
{
Console.Title = "IMVU Hp Image Ripper";
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Clear();
Console.WriteLine("Enter a hp url or file path and hit enter:");
Console.WriteLine("");
input = Console.ReadLine();

if (input == "")
{
Console.Clear();
Console.Write("No input specified, press enter to return");
Console.ReadLine();
menu();
}
else
{
if (File.Exists(input))
{
file = true;
}
else
{
if (!input.Contains("http://imvu-customer-sandbox.com/"))
{
if (!input.Contains("http://") && input.Contains("imvu-customer-sandbox.com/"))
{
Console.WriteLine("Adding http://");
input = string.Concat("http://", input);
}
else if (!input.Contains("http://") && !input.Contains("imvu-customer-sandbox.com/"))
{
Console.WriteLine("Adding full url");
input = string.Concat("http://imvu-customer-sandbox.com/", input);
}
else
{
Console.Clear();
Console.Write("Invalid input, press enter to return");
Console.ReadLine();
menu();
}
}
}
}

Console.WriteLine("");
Console.WriteLine("Choose operation:");
Console.WriteLine("1 - Rip Stickers");
Console.WriteLine("2 - Rip Display Picture");
Console.WriteLine("3 - Rip All");
Console.WriteLine("");
imgtype = Console.ReadLine();

switch (imgtype)
{
case "1":
stickers = true;
displaypic = false;
break;
case "2":
stickers = false;
displaypic = true;
break;
case "3":
stickers = true;
displaypic = true;
break;
}
dl_imgs();
}

private static void dl_imgs()
{
if (!Directory.Exists(Environment.CurrentDirectory + "\\Downloaded"))
{
Directory.CreateDirectory(Environment.CurrentDirectory + "\\Downloaded");
}

if (file == true)
{
string[] lines = System.IO.File.ReadAllLines(input);
foreach (string line in lines)
{
try
{
HtmlDocument document = new HtmlWeb().Load(line);
var imagetags = document.DocumentNode.SelectNodes("//img");

if (imagetags != null)
{
foreach (var image in imagetags)
{
if (stickers == true)
{
if (image.Attributes["class"] != null)
{
if (image.Attributes["class"].Value == "imvuSticker")
{
if (!File.Exists(@"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value)))
{
using (WebClient client = new WebClient())
{
client.DownloadFile(image.Attributes["src"].Value, @"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value));
}
string fname = line.Replace("http://imvu-customer-sandbox.com/", "");
Console.WriteLine(string.Format("Downloaded: {0} - {1}", fname, Path.GetFileName(image.Attributes["src"].Value)));
}
else
{
Console.WriteLine("File Exists, Skipping");
}
}
}
}
if (displaypic == true)
{
if (image.Attributes["alt"] != null)
{
if (image.Attributes["alt"].Value == "avpic")
{
if (!File.Exists(@"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value)))
{
using (WebClient client = new WebClient())
{
client.DownloadFile(image.Attributes["src"].Value, @"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value));
}
string fname = line.Replace("http://imvu-customer-sandbox.com/", "");
Console.WriteLine(string.Format("Downloaded: {0} - {1}", fname, Path.GetFileName(image.Attributes["src"].Value)));
}
else
{
Console.WriteLine("File Exists, Skipping");
}
}
}
}
}
}
else
{
Console.WriteLine("No Images Found, Skipping Page");
}
}
catch (HtmlWebException e)
{
Console.Write("HtmlWebException");
Console.Write("line: " + line);
Console.Write(e.Message);
}
catch (WebException e)
{
Console.Write("WebException");
Console.Write("line: " + line);
Console.Write(e.Message);
}
}
}
else if (file == false)
{
try
{
HtmlDocument document = new HtmlWeb().Load(input);
var imagetags = document.DocumentNode.SelectNodes("//img");

if (imagetags != null)
{
foreach (var image in imagetags)
{
if (stickers == true)
{
if (image.Attributes["class"] != null)
{
if (image.Attributes["class"].Value == "imvuSticker")
{
if (!File.Exists(@"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value)))
{
using (WebClient client = new WebClient())
{
client.DownloadFile(image.Attributes["src"].Value, @"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value));
}
string fname = input.Replace("http://imvu-customer-sandbox.com/", "");
Console.WriteLine(string.Format("Downloaded: {0} - {1}", fname, Path.GetFileName(image.Attributes["src"].Value)));
}
else
{
Console.WriteLine("File Exists, Skipping");
}
}
}
}
if (displaypic == true)
{
if (image.Attributes["alt"] != null)
{
if (image.Attributes["alt"].Value == "avpic")
{
if (!File.Exists(@"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value)))
{
using (WebClient client = new WebClient())
{
client.DownloadFile(image.Attributes["src"].Value, @"Downloaded\" + Path.GetFileName(image.Attributes["src"].Value));
}
string fname = input.Replace("http://imvu-customer-sandbox.com/", "");
Console.WriteLine(string.Format("Downloaded: {0} - {1}", fname, Path.GetFileName(image.Attributes["src"].Value)));
}
else
{
Console.WriteLine("File Exists, Skipping");
}
}
}
}
}
}
else
{
Console.WriteLine("No Images Found, Skipping Page");
}
}
catch (HtmlWebException e)
{
Console.WriteLine("HtmlWebException");
Console.WriteLine(e.Message);
}
catch (WebException e)
{
Console.WriteLine("WebException");
Console.WriteLine(e.Message);
}
}
Console.WriteLine("");
Console.WriteLine("Done, Return To Menu?");
Console.WriteLine("1 - Yes");
Console.WriteLine("2 - No");
rtrn = Console.ReadLine();

switch (rtrn)
{
case "1":
menu();
break;
case "2":
Environment.Exit(0);
break;
}
}
}
}[/code]
Posted 12 years ago
Sweet, glad to see this up and running.
Posted 12 years ago · Author
Don Von Free Credits wrote:
Can you describe the output a bit more and how it is packaged?


The output on the console is the current homepage it's looking at and the stickers it's downloading. If it skips a homepage (because it doesn't exist, has no stickers or is ap etc..) then you will just see the homepage url and that's it. Otherwise, if it locates stickers, it will show the homepage url and a list of downloaded stickers underneath it.

Image


As for the file output, it will generate a folder in the same location as the executable and save all the stickers into it.

As for packaged, I am not sure what you mean. I hope this is the explanation you wanted.
Posted 12 years ago
what program should i download to get this sticker grabber to work ??
Posted 12 years ago · Author
XunknownX wrote:
what program should i download to get this sticker grabber to work ??



Pick one from the list of IDEs Don Von linked you too.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT