Created
August 12, 2013 16:02
-
-
Save lfreneda/6212282 to your computer and use it in GitHub Desktop.
imdb info :p
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.Globalization; | |
using System.Threading; | |
using SimpleBrowser; | |
namespace ConsoleApplication19 | |
{ | |
public static class StringExtensions | |
{ | |
public static void Print(this string str, string prefix = null) | |
{ | |
Console.WriteLine("{0}: {1}", prefix, str); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var culture = new CultureInfo("en-US"); | |
Thread.CurrentThread.CurrentCulture = culture; | |
Thread.CurrentThread.CurrentUICulture = culture; | |
var b = new SimpleBrowser.Browser(); | |
b.SetHeader("Accept-Language: en;q=0.8"); | |
if (b.Navigate("http://www.imdb.com/title/tt0133093")) | |
{ | |
var title = b.Select("h1.header span.itemprop").DecodedValue.Trim(); | |
title.Print("Titulo Original"); | |
var year = b.Select("h1.header span.nobr a").DecodedValue.Trim(); | |
year.Print("Ano"); | |
var rating = b.Select(".star-box-giga-star").DecodedValue.Trim(); | |
rating.Print("Rating"); | |
var shortDescription = b.Select("p[itemprop='description']").DecodedValue.Trim(); | |
shortDescription.Print("Descrição"); | |
var directors = b.Select("div[itemprop='director']"); | |
var directorsNames = directors.Select("span[itemprop='name']"); | |
foreach (var directorsName in directorsNames) | |
{ | |
directorsName.DecodedValue.Trim().Print("Director"); | |
} | |
var creators = b.Select("div[itemprop='creator']"); | |
var creatorsNames = creators.Select("span[itemprop='name']"); | |
foreach (var creatorsName in creatorsNames) | |
{ | |
creatorsName.DecodedValue.Trim().Print("Creator"); | |
} | |
var stars = b.Select("div[itemprop='actors']"); | |
var starsNames = stars.Select("span[itemprop='name']"); | |
foreach (var starsName in starsNames) | |
{ | |
starsName.DecodedValue.Trim().Print("Star"); | |
} | |
var storyLineContainer = b.Select("#titleStoryLine"); | |
var storyLineUnformatted = storyLineContainer.Select("div[itemprop='description']"); | |
HtmlResult htmlResult = storyLineUnformatted.Select("p em"); | |
if (htmlResult.Exists) | |
{ | |
var removeIt = htmlResult.DecodedValue.Trim(); | |
var storyLine = storyLineUnformatted.DecodedValue.Trim().Replace(removeIt, ""); | |
storyLine.Print("História"); | |
} | |
else | |
{ | |
storyLineUnformatted.DecodedValue.Trim().Print("História"); | |
} | |
var genresContainer = storyLineContainer.Select("div[itemprop='genre']"); | |
var genres = genresContainer.Select("a"); | |
foreach (var genre in genres) | |
{ | |
genre.DecodedValue.Trim().Print("Genre"); | |
} | |
var keywordsContainer = storyLineContainer.Select("div[itemprop='genre']"); | |
var keywords = keywordsContainer.Select("a"); | |
foreach (var keyword in keywords) | |
{ | |
keyword.DecodedValue.Trim().Print("Keyword"); | |
} | |
} | |
else | |
{ | |
"Didn't work".Print(); | |
} | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment