Esempio n. 1
0
		private static void RedditSearch()
		{
			var parser = new StandardHtmlParser(AnonymousStructure.FixedObject);

			parser.Binder.Processors.Add("commentCount", (value, arguments, alias) => ((string) value).Split(' ')[0]);

			var binding = HtmlBinding.Load(BindingPath("RedditSearch.hb"));

			Console.WriteLine(binding);

			Console.Write("Query: ");
			var query = Console.ReadLine();
			Console.WriteLine();

			var list = Html("https://www.reddit.com/search?q=" + query);

			var results = parser.Parse<dynamic[]>(binding, list);

			Process.Start(results[0].Link);

			foreach (var result in results)
			{
				Console.WriteLine(result.ToDebugString());

				Console.WriteLine();
			}

			Console.WriteLine("Done.");

			Console.ReadLine();
		}
Esempio n. 2
0
		private static void Example()
		{
			var parser = new StandardHtmlParser(AnonymousStructure.ExpandoObject);

			var binding = HtmlBinding.Load(@"C:\binding.hb");

			var html = new WebClient().DownloadString("http://example.com");

			var results = parser.Parse<dynamic[]>(binding, html);

			Console.WriteLine(results[0].Title);
		}