Example #1
0
		public void DownloadHtmlPageExperiment()
		{
			Uri address = UserInputUrl(Text.PromptFormat, Instructions.EnterAUrl);

			TraceLine(Text.Subscribing);
			TraceLine();

			using (var client = new WebClient())
			{
				var htmlTagsWithIds = client
					.DownloadStringObservable(address)
					.SelectMany(response =>
						Regex.Matches(
							response,
							@"\< (?<Tag> \w+? ) \s [^\>]*? id= (?<Q> [""']? ) (?<ID> .+? ) \k<Q> .*? \>",
								RegexOptions.IgnoreCase
							| RegexOptions.ExplicitCapture
							| RegexOptions.IgnorePatternWhitespace
							| RegexOptions.Singleline)
						.Cast<Match>())
					.Select(match => new
					{
						Tag = match.Groups["Tag"].Value,
						Id = match.Groups["ID"].Value
					});

				using (htmlTagsWithIds.Subscribe(ConsoleOutput))
				{
					TraceLine(Instructions.PressAnyKeyToCancel);

					WaitForKey();
				}
			}
		}