Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace imdb_parser_2
- {
- class Program
- {
- static void Main(string[] args)
- {
- StreamReader sr = new StreamReader("nagydb.txt");
- StreamWriter sw = new StreamWriter("datacollection.txt");
- sw.AutoFlush = true;
- //Számláló
- int counter = 0;
- //Film linkjének beolvasása
- string link = sr.ReadLine();
- while(!sr.EndOfStream)
- {
- //Előkészítjük az adott filmet az adatok befogadására
- var CurrentMovie = new movie();
- //Beírjuk a filmbe az adatokat
- CurrentMovie.SetData(link);
- sw.WriteLine(WebUtility.HtmlDecode(CurrentMovie.title) + ";" + CurrentMovie.plot + ";" + CurrentMovie.img);
- counter++;
- Console.WriteLine(counter);
- link = sr.ReadLine();
- }
- }
- }
- public class movie
- {
- // Field
- public string title;
- public string plot;
- public string year;
- public string link;
- public string img;
- // Constructor
- public movie()
- {
- title = "unknown title";
- plot = "no plot";
- year = "no year";
- }
- // Method
- public void SetData(string link)
- {
- try
- {
- IMDb imdb_movie = new IMDb(link, false);
- title = imdb_movie.Title;
- plot = WebUtility.HtmlDecode(imdb_movie.Plot);
- year = WebUtility.HtmlDecode(imdb_movie.Year);
- img = WebUtility.HtmlDecode(imdb_movie.Poster);
- }
- catch (Exception e)
- {
- Console.WriteLine("Hiba történt, folytatom!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement