Created
January 30, 2012 05:28
-
-
Save kendaganio/1702728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Net; | |
using System.Text.RegularExpressions; | |
using System.Collections; | |
using System.IO; | |
namespace PeteApplication1 | |
{ | |
class Program | |
{ | |
static LinkedList<Match> list = new LinkedList<Match>(); | |
public static void getImages(String url) | |
{ | |
Console.WriteLine(url); | |
if (!url.Contains("http://")) | |
{ | |
url = "http://" + url; | |
} | |
WebClient w = new WebClient(); | |
String s = w.DownloadString(url); | |
MatchCollection m = Regex.Matches(s, @"[a-z0-9]*[.][a-z]*[.]+[/\w+]+\w+[.]jpg", RegexOptions.IgnoreCase); | |
foreach (Match ma in m) | |
{ | |
Console.WriteLine(ma); | |
list.AddFirst(ma); | |
} | |
m = Regex.Matches(s, @"\w+[.]gif", RegexOptions.IgnoreCase); | |
foreach (Match ma in m) | |
{ | |
list.AddFirst(ma); | |
} | |
w.Dispose(); | |
} | |
static void Main(string[] args) | |
{ | |
//http://9gag.com/hot/5294 | |
//Console.Write("Gimme a site: "); | |
//String url = Console.ReadLine(); | |
for (int i = 5295; i > 5290; i--) | |
{ | |
getImages("9gag.com/hot/" + i); | |
} | |
TextWriter tw = new StreamWriter("a.html"); | |
tw.WriteLine("<html><head></head><body>"); | |
foreach(Match ma in list){ | |
tw.WriteLine("<img src=\"http://" + ma.ToString() + "\"><br>"); | |
} | |
tw.WriteLine("</body></html>"); | |
tw.Close(); | |
Console.WriteLine("Done!"); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment