Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var keywords = new[] { "GET", "DELETE", "PATCH", "POST" };
var document =new HtmlDocument();
document .LoadHtml(
(new HtmlWeb()
.Load("https://developer.github.com/v3/")
.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[3]/div[2]/div[1]").ChildNodes
.Select(cn => cn.InnerHtml)
.Where(cn => !string.IsNullOrEmpty(cn.Trim()))
.First()));
var dictionary = document.DocumentNode.SelectNodes("//a")
.Select(p => new
{
Key = p.GetAttributeValue("href", "not found").Replace("/v3", ""),
Value = "https://developer.github.com" + p.GetAttributeValue("href", "not found")
})
.Where(p => p.Key.Trim() != "#" & p.Key.Trim() != "/")
.ToDictionary(p => p.Key, p => p.Value)
.OrderBy(p => p.Key);
var newapis = new Func<string, IEnumerable<string>>((url) =>
{
try
{
return new HtmlWeb()
.Load(url)
.DocumentNode.SelectSingleNode("//*[@id=\"wrapper\"]/div[1]").SelectNodes("//pre")
.Select(dn => dn.InnerText)
.Where(cn => keywords
.Contains(
Regex.Split(cn, "[^a-zA-Z]+").First() /*split first word*/)).ToList();
}
catch (Exception ex)
{
return new[] {""};
}
});
//these things don't have any API's - troubleshooting, versions,/activity/events/types/, auth
dictionary.ToObservable()
.Select(d => new {Key = d.Key, Values = newapis(d.Value) })
.Dump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.