C# Imvu Icon Downloader - Console App [Updated 9-23-2012]

DataMine
by DataMine · 2 posts
12 years ago in .Net (C#, VB, etc)
Posted 12 years ago · Author
This is the console version of my Icon downloader. It doesn't support login yet, still working on getting the HtmlAgilityPack to accept cookies. It supports all areas of the catalog and will loop through and download every product icon on the page till you tell it to stop.

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.

If you want to rip ap icons, see my other icon downloader here: https://www.imvumafias.org/community/viewtop ... 109&t=8061

Image

Image

[cod]using System;
using System.Collections.Generic;
using HtmlAgilityPack;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
class Program
{
private static string category = "";
private static string url = "http://www.imvu.com/shop/web_browse.php?cat=106-41&page=";
private static string dir = "";

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

private static void menu()
{
Console.Clear();
Console.Title = "IMVU Icon Downloader";
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Select A Category To Download From:");
Console.WriteLine("-------------------------------------");
Console.WriteLine("1 - Men's Clothing");
Console.WriteLine("2 - Women's Clothing");
Console.WriteLine("3 - Furniture");
Console.WriteLine("4 - Rooms");
Console.WriteLine("5 - Avatars");
Console.WriteLine("6 - Stickers");
Console.WriteLine("7 - Enter A Custom Url");
Console.WriteLine("");
category = Console.ReadLine();

switch(category)
{
case "1":
url = "http://www.imvu.com/shop/web_browse.php?cat=106-41&page=";
break;
case "2":
url = "http://www.imvu.com/shop/web_browse.php?cat=106-40&page=";
break;
case "3":
url = "http://www.imvu.com/shop/web_browse.php?cat=107-1027&page=";
break;
case "4":
url = "http://www.imvu.com/shop/web_browse.php?cat=107-366&page=";
break;
case "5":
url = "http://www.imvu.com/shop/web_browse.php?cat=108&page=";
break;
case "6":
url = "http://www.imvu.com/shop/web_browse.php?cat=495&page=";
break;
case "7":
Console.Clear();
Console.WriteLine("Please type or paste in a product page url");
Console.WriteLine("");
url = Console.ReadLine();
break;
}

if (!url.Contains("www.imvu.com/shop/web_search.php?") && !url.Contains("www.imvu.com/shop/web_browse.php?"))
{
Console.Clear();
Console.Write("Invalid Url, Press Any Key To Return");
Console.ReadLine();
menu();
}

if (!url.Contains("&page="))
{
if (url.Contains("&") && !url.Contains("&page"))
{
url = string.Concat(url, "page=");
}
else if (url.Contains("&page") && !url.Contains("&page="))
{
url = string.Concat(url, "=");
}
else
{
url = string.Concat(url, "&page=");
}
}

if (!url.Contains("http://"))
{
url = string.Concat("http://", url);
}

get_files(1);
}

private static void get_files(int page = 1)
{
HtmlNode.ElementsFlags.Remove("option");

try
{
HtmlDocument document = new HtmlWeb().Load(url + page);

if (page == 1)
{
var optags = document.DocumentNode.SelectNodes("//option");
if (optags != null)
{
foreach (HtmlNode op in optags)
{
if (op.InnerText.Contains("Products by") && !op.InnerText.Contains("Creator"))
{
if (!Directory.Exists(Environment.CurrentDirectory + "\\" + op.InnerText))
{
Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + op.InnerText);
}
dir = Environment.CurrentDirectory + "\\" + op.InnerText;
}
}
}
if (dir == "")
{
if (!Directory.Exists(Environment.CurrentDirectory + "\\Downloaded"))
{
Directory.CreateDirectory(Environment.CurrentDirectory + "\\Downloaded");
}
dir = Environment.CurrentDirectory + "\\Downloaded";
}
}

var icons = document.DocumentNode.SelectNodes("//img[@class=\"thumbnail\"]");

if (icons != null)
{
foreach (HtmlNode icon in (IEnumerable<HtmlNode>)icons)
{
using (WebClient client = new WebClient())
{
client.DownloadFile(icon.Attributes["src"].Value, dir + "\\" + Path.GetFileName(icon.Attributes["src"].Value));
}
Console.WriteLine(string.Format("Downloaded (Page: {0}) - {1}", page, Path.GetFileName(icon.Attributes["src"].Value)));
}
get_files(page + 1);
}
else
{
Console.WriteLine("");
Console.WriteLine("No Icons Found Or End Of Pages Reached, Press Any Key To Return To Menu");
Console.ReadLine();
menu();
}
}
catch (HtmlWebException)
{
get_files(page + 1);
}
catch (WebException)
{
get_files(page + 1);
}
}
}
}[/code]
Posted 12 years ago
This'll help a lot if you are an icon ripper. Let it run and edit.

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