Skip to content

Instantly share code, notes, and snippets.

@EgorBo
Created Sep 1, 2022
Embed
What would you like to do?
blogpost-parser.cs
using System.Text.RegularExpressions;
string file = await new HttpClient().GetStringAsync(
"https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7/");
MatchCollection pullRequestUrls =
Regex.Matches(file, @"https:\/\/github.com\/[a-zA-Z-]+\/[a-zA-Z-]+\/pull\/[0-9]+");
int total = pullRequestUrls.Count;
int i = 1;
List<string> authors = new();
foreach (var pullRequestUrl in pullRequestUrls.Select(m => m.ToString().Trim()).Distinct())
{
string content = await new HttpClient().GetStringAsync(pullRequestUrl);
string title = Regex.Match(content, @"<title>(.*?)<\/title>").Value
.Replace("<title>","")
.Replace("</title>", "")
.Trim();
if (!title.Contains(" · Pull Request #"))
{
// there are 6 links which are github issues rather than PRs despite /pull/ in the url
continue;
}
title = title.Substring(0, title.IndexOf(" · Pull Request #"));
string nick = title.Substring(title.LastIndexOf(" by ") + " by ".Length).Trim();
Console.WriteLine($"{i++}/{total}: {title}");
authors.Add(nick);
}
foreach (var author in authors.GroupBy(g => g).OrderByDescending(g => g.Count()))
{
Console.WriteLine(author.Key.PadRight(
authors.Select(a => a.Length).Max() + 1) + " -- " + author.Count());
}
/*
stephentoub -- 148
EgorBo -- 45
tannergooding -- 26
vcsjones -- 23
adamsitnik -- 17
elinor-fung -- 14
AndyAyersMS -- 10
wfurt -- 9
eiriktsarpalis -- 9
TIHan -- 8
jkoritzinsky -- 8
AaronRobinsonMSFT -- 7
bartonjs -- 7
kunalspathak -- 6
simonrozsival -- 6
BruceForstall -- 5
jkotas -- 5
kouvel -- 5
teo-tsirpanis -- 5
olsaarik -- 5
joperezr -- 5
tmds -- 5
SingleAccretion -- 4
MichalStrehovsky -- 4
vargaz -- 4
fanyang-mono -- 4
GrabYourPitchforks -- 4
AlekseyTs -- 4
eerhardt -- 4
jakobbotsch -- 3
echesakov -- 3
steveharter -- 3
alexcovington -- 3
SwapnilGaikwad -- 3
NewellClark -- 3
filipnavara -- 3
TrayanZapryanov -- 3
CodeBlanch -- 3
BrzVlad -- 2
mkhamoyan -- 2
huoyaoyuan -- 2
SergeiPavlov -- 2
am11 -- 2
gfoidl -- 2
veanes -- 2
Clockwork-Muse -- 2
lateapexearlyspeed -- 2
bgrainger -- 2
MihaZupan -- 2
geoffkizer -- 2
kronic -- 2
Cosifne -- 2
hez2010 -- 1
anthonycanino -- 1
pentp -- 1
SeanWoo -- 1
janvorli -- 1
weilinwa -- 1
JulieLeeMSFT -- 1
Wraith2 -- 1
mangod9 -- 1
radekdoulik -- 1
VSadov -- 1
AntonLapounov -- 1
CarlVerret -- 1
madelson -- 1
MichalPetryka -- 1
key-moon -- 1
sakno -- 1
nietras -- 1
yesmey -- 1
a74nh -- 1
cston -- 1
YairHalberstadt -- 1
RikkiGibson -- 1
grbell-ms -- 1
RaymondHuy -- 1
johnthcall -- 1
deeprobin -- 1
pedrobsaila -- 1
rzikm -- 1
onehourlate -- 1
krwq -- 1
strobelt -- 1
chrisdcmoore -- 1
SteveDunn -- 1
schuettecarsten -- 1
Bibletoon -- 1
BrennanConroy -- 1
CollinAlpert -- 1
buyaa-n -- 1
chucker -- 1
wzchua -- 1
pawchen -- 1
marek-safar -- 1
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment