Created
March 17, 2014 07:02
-
-
Save diegomichell/9595088 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.Net; | |
using System.Text.RegularExpressions; | |
/* | |
* Creado por: Diego Ivan Perez Michel | |
* Matricula: 2013-1488 | |
*/ | |
namespace Web | |
{ | |
public class WebReader | |
{ | |
private WebClient client = new WebClient(); | |
private string webContent; | |
private string titulo {get;set;} | |
int cantidadP = 0; | |
int cantidadDiv = 0; | |
int cantidadCaracteres = 0; | |
int cantidadJs = 0; | |
int cantidadCss = 0; | |
int cantidadImg = 0; | |
public WebReader() | |
{ | |
Console.WriteLine("\t\tWeb Analizer: Creado por Diego Ivan Perez Michel\n"); | |
webContent = client.DownloadString(LeerUrl()); | |
//Cantidad de veces en que aparece cada etiqueta | |
cantidadP = Regex.Matches(webContent,"<p").Count; | |
cantidadDiv = Regex.Matches(webContent,"<div").Count; | |
cantidadImg = Regex.Matches(webContent,"<img").Count; | |
cantidadCss = Regex.Matches(webContent,"<link").Count; | |
cantidadJs = Regex.Matches(webContent,"<script").Count; | |
//Cantidad de caracteres en la pagina | |
cantidadCaracteres = webContent.Length; | |
} | |
public string LeerUrl(){ | |
Console.Write("Introduzca una URL:"); | |
return Console.ReadLine(); | |
} | |
public static void Main(string[] args) | |
{ | |
Console.Clear(); | |
WebReader reader = new WebReader(); | |
Console.WriteLine("Cantidad de Etiquetas\n"); | |
Console.WriteLine("<p> = {0}",reader.cantidadP); | |
Console.WriteLine("<img> = {0}",reader.cantidadImg); | |
Console.WriteLine("<div> = {0}",reader.cantidadDiv); | |
Console.WriteLine("<link> = {0}",reader.cantidadCss); | |
Console.WriteLine("<script> = {0}",reader.cantidadJs); | |
Console.WriteLine("\nCantidad de Caracteres"); | |
Console.WriteLine("Caracteres: {0}",reader.cantidadCaracteres); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment