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.
[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]
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.
[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]