| [C#] Simple UrlDump Program [.NET] | |
|
Author | Message |
---|
Sunder
Posts : 21 Age : 30 Location : Upstate New York
| Subject: [C#] Simple UrlDump Program [.NET] Mon Jan 02, 2012 5:11 am | |
| I had to help someone with this, so I figured I'd share this small but surprisingly useful bit of code. What it does is get all the IP addresses from a website's url and saves it to a file. This is a fairly complete program, and quite useful, so enjoy. - Code:
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO;
namespace UrlDump { class Program { static void Main(string[] args) { try { string url; List<string> AddressList = new List<string>();//Create a list for us to store our strings in. Console.WriteLine("Enter a website."); url = Console.ReadLine(); IPAddress[] AddressArray = Dns.GetHostAddresses(url);//Get a collection of addresses for the specified host or site. foreach (IPAddress addr in AddressArray)//Add each one to our list. { AddressList.Add(addr.ToString()); } string[] Addresses = AddressList.ToArray<string>();//Create an array from that list. File.AppendAllLines(url + ".txt", Addresses);//Write the array to the file. Console.WriteLine("Addresses Recorded. Press any key to exit."); Console.ReadLine();//If nothing went wrong, process will exit. } catch (Exception e) { File.AppendAllText("ErrorMessage.txt", e.Message); File.AppendAllText("ErrorStackTrace", e.StackTrace); } } } }
If anyone has a request for a different version of this, or a request for any program really, let me know. Edit: The forum smushes the code and forces it to be word-wrapped to the next line if it's too long, so copy/paste to Visual Studio. It should run when you press F5. |
|
| |
Avith
Posts : 115
| Subject: Re: [C#] Simple UrlDump Program [.NET] Mon Jan 02, 2012 6:32 am | |
| - Sunder wrote:
- I had to help someone with this, so I figured I'd share this small but surprisingly useful bit of code. What it does is get all the IP addresses from a website's url and saves it to a file. This is a fairly complete program, and quite useful, so enjoy.
- Code:
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO;
namespace UrlDump { class Program { static void Main(string[] args) { try { string url; List<string> AddressList = new List<string>();//Create a list for us to store our strings in. Console.WriteLine("Enter a website."); url = Console.ReadLine(); IPAddress[] AddressArray = Dns.GetHostAddresses(url);//Get a collection of addresses for the specified host or site. foreach (IPAddress addr in AddressArray)//Add each one to our list. { AddressList.Add(addr.ToString()); } string[] Addresses = AddressList.ToArray<string>();//Create an array from that list. File.AppendAllLines(url + ".txt", Addresses);//Write the array to the file. Console.WriteLine("Addresses Recorded. Press any key to exit."); Console.ReadLine();//If nothing went wrong, process will exit. } catch (Exception e) { File.AppendAllText("ErrorMessage.txt", e.Message); File.AppendAllText("ErrorStackTrace", e.StackTrace); } } } }
If anyone has a request for a different version of this, or a request for any program really, let me know.
Edit: The forum smushes the code and forces it to be word-wrapped to the next line if it's too long, so copy/paste to Visual Studio. It should run when you press F5. Most people will take your coding skills more seriously if you compile your program/file as well |
|
| |
Sunder
Posts : 21 Age : 30 Location : Upstate New York
| Subject: Re: [C#] Simple UrlDump Program [.NET] Mon Jan 02, 2012 3:29 pm | |
| Yeah, I was thinking about that last night. I think what I'll do is a collection of tools, utilities, and other programs that I've made and put them in an installer program and upload that. |
|
| |
Avith
Posts : 115
| Subject: Re: [C#] Simple UrlDump Program [.NET] Mon Jan 02, 2012 4:34 pm | |
| - Sunder wrote:
- Yeah, I was thinking about that last night. I think what I'll do is a collection of tools, utilities, and other programs that I've made and put them in an installer program and upload that.
Upload the to mediafire when your finished |
|
| |
8bit
Posts : 39 Age : 30 Location : Cyberspace
| Subject: Re: [C#] Simple UrlDump Program [.NET] Tue Jan 03, 2012 11:29 am | |
| - Avith wrote:
- Sunder wrote:
- Yeah, I was thinking about that last night. I think what I'll do is a collection of tools, utilities, and other programs that I've made and put them in an installer program and upload that.
Upload the to mediafire when your finished Hey Bro If You Want I Can Create A FTP Server For Us |
|
| |
Sunder
Posts : 21 Age : 30 Location : Upstate New York
| Subject: Re: [C#] Simple UrlDump Program [.NET] Tue Jan 03, 2012 8:21 pm | |
| An FTP server would be handy, good idea. |
|
| |
8bit
Posts : 39 Age : 30 Location : Cyberspace
| Subject: Re: [C#] Simple UrlDump Program [.NET] Tue Jan 03, 2012 8:39 pm | |
| - Sunder wrote:
- An FTP server would be handy, good idea.
If You Want I Can Get Started Making The Server. |
|
| |
Avith
Posts : 115
| Subject: Re: [C#] Simple UrlDump Program [.NET] Tue Jan 03, 2012 8:59 pm | |
| - 8bit wrote:
- Sunder wrote:
- An FTP server would be handy, good idea.
If You Want I Can Get Started Making The Server. You Should, and I'm thinking about making a advertisement team to get this site more popular |
|
| |
Laser
Posts : 116 Age : 27
| Subject: Re: [C#] Simple UrlDump Program [.NET] Tue Jan 03, 2012 9:17 pm | |
| if you do i will advertise |
|
| |
8bit
Posts : 39 Age : 30 Location : Cyberspace
| Subject: Re: [C#] Simple UrlDump Program [.NET] Tue Jan 03, 2012 9:27 pm | |
| - Avith wrote:
- 8bit wrote:
- Sunder wrote:
- An FTP server would be handy, good idea.
If You Want I Can Get Started Making The Server. You Should, and I'm thinking about making a advertisement team to get this site more popular OK Already Made One That Has 1,000,000 Gb Of Memory |
|
| |
Sponsored content
| Subject: Re: [C#] Simple UrlDump Program [.NET] | |
| |
|
| |
| [C#] Simple UrlDump Program [.NET] | |
|