using System.Diagnostics;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;
public static void Main()
Action scrape = (async () => await ScrapeManifesto("Carlos Rodarte"));
public static async Task ScrapeManifesto(string name)
string url = "https://agilemanifesto.org/display";
string uriManifesto = $"{url}/index.html";
string uriManifesto2 = $"{url}/000000001.html";
string html = await (new WebClient().DownloadStringTaskAsync(new Uri(uriManifesto)));
var uris = html.LRParser(StringExtension.Tokenizer, "href", @".html").Aggregate(new Dictionary<string, string>(), (c, n) =>
c.Add(n.Key, $"{url}/{(n.Value as string)?.Replace("href", "").Replace("=", "").Replace($"\"", "")}");
List<string> list = new List<string>();
foreach (var uri in uris)
Task<string> t1 = new WebClient().DownloadStringTaskAsync(new Uri(uri.Value));
var task = t1.ContinueWith(_ =>
if (t1.Exception != null)
t1.Exception.InnerException.Dump();
string htmlContent = t1.Result;
if (htmlContent.Contains(name))
Console.WriteLine(uri.Value);
Console.WriteLine($"{e.Message}\r\n{uri.Value}");
public static class StringExtension
public static Dictionary<string, object> Tokenizer(string prefix, string body, string postfix)
Dictionary<string, object> parsedTokens = new Dictionary<string, object>();
parsedTokens.Add(Guid.NewGuid().ToString(), String.Format("{0}{1}{2}", prefix, body, postfix));
public static TResult LRParser<TResult>(this String text, Func<string, string, string, TResult> tokenizer, string beginToken, string endToken)
where TResult : IDictionary<string, object>, new()
TResult parsedTokens = new TResult();
string matchedBeginToken = String.Empty;
string matchedEndToken = String.Empty;
string lookahead = text.LRPostfixify(beginToken, out matchedBeginToken);
string body = lookahead.LRPrefixify(endToken, out matchedEndToken);
string nextPass = text.LRPostfixify(endToken);
if (!string.IsNullOrEmpty(body))
tokenizer(matchedBeginToken, body, matchedEndToken).Aggregate(parsedTokens, (c, n) =>
if (!string.IsNullOrEmpty(nextPass))
nextPass.LRParser(tokenizer, beginToken, endToken).Aggregate(parsedTokens, (c, n) =>
if (!c.ContainsKey(n.Key))
public static string LRPostfixify(this String word, string patternMarker, bool nullify = true)
string matched = String.Empty;
if (String.IsNullOrWhiteSpace(word))
return word.LRPostfixify(patternMarker, out matched, nullify);
public static string LRPostfixify(this String word, string patternMarker, out string matchedMarker, bool nullify = true)
matchedMarker = String.Empty;
if (String.IsNullOrWhiteSpace(word) || String.IsNullOrEmpty(patternMarker))
var match = Regex.Match(word, patternMarker, RegexOptions.IgnoreCase);
matchedMarker = match.Captures[0].Value;
string postfixified = word.LRPostfix(matchedMarker);
return nullify ? null : word;
public static string LRPrefixify(this String word, string patternMarker, out string matchedMarker, bool nullify = true)
matchedMarker = String.Empty;
if (String.IsNullOrWhiteSpace(word) || String.IsNullOrEmpty(patternMarker))
var match = Regex.Match(word, patternMarker, RegexOptions.IgnoreCase);
matchedMarker = match.Captures[0].Value;
string prefixified = word.LRPrefix(matchedMarker);
if (String.IsNullOrWhiteSpace(prefixified) || String.IsNullOrEmpty(prefixified))
return nullify ? null : word;
public static string LRPrefix(this String word, string marker, bool nullify = true)
if (!string.IsNullOrEmpty(marker) && !string.IsNullOrEmpty(word))
int res = word.IndexOf(marker, 0, StringComparison.OrdinalIgnoreCase);
return word.Substring(0, word.IndexOf(marker, StringComparison.OrdinalIgnoreCase));
return nullify ? null : word;
public static string LRPostfix(this String word, string marker, bool nullify = true)
if (!string.IsNullOrEmpty(marker) && !string.IsNullOrEmpty(word))
int res = word.IndexOf(marker, 0, StringComparison.OrdinalIgnoreCase);
return word.Substring(word.IndexOf(marker, 0, StringComparison.OrdinalIgnoreCase) + marker.Length);
return nullify ? null : word;