Skip to content

Commit

Permalink
2nd update of results
Browse files Browse the repository at this point in the history
  • Loading branch information
rrelyea committed Sep 28, 2023
1 parent 19b181f commit 3481a22
Show file tree
Hide file tree
Showing 2 changed files with 2,023 additions and 11 deletions.
32 changes: 22 additions & 10 deletions tools/WikiLinks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async Task ProcessAllPages(WikiSite wikiSite) {

foreach (var page in pages) {
await ProcessPage(page);
await ProcessPage(page, talkNamespace:true);
//await ProcessPage(page, talkNamespace:true);
}
}

Expand Down Expand Up @@ -108,16 +108,28 @@ async Task<bool> ProcessLink(string? pageTitle, string? linkUrl, bool headerShow
if (response.Headers.Location != null) {
Console.WriteLine(" redirected to " + response.Headers.Location + " from " + linkUrl);
} else {
if (response.ReasonPhrase == "Bad Request" || response.ReasonPhrase == "Internal Server Error") {
var newUrl = linkUrl?.Replace("http://", "https://");
(HttpResponseMessage? response2, Exception? e2) = await FetchUrl(newUrl);
if (response2 != null && response2.IsSuccessStatusCode) {
Console.WriteLine(" Update to use https. " + " " + linkUrl);
} else {
switch (response.ReasonPhrase) {
case "Bad Request":
var newUrl = linkUrl?.Replace("http://", "https://");
(HttpResponseMessage? response2, Exception? e2) = await FetchUrl(newUrl);
if (response2 != null && response2.IsSuccessStatusCode) {
Console.WriteLine(" Update to use https. " + " " + linkUrl);
} else {
Console.WriteLine(" " + response.ReasonPhrase + " " + linkUrl);
}
break;
case "Too Many Requests":
if (!linkUrl.StartsWith("http://ssrn.com/abstract")) {
Console.WriteLine(" " + response.ReasonPhrase + " " + linkUrl);
}
break;
// These reasons should be ignored, not a problem that requires a URL change.
case "Unauthorized":
case "Internal Server Error":
break;
default:
Console.WriteLine(" " + response.ReasonPhrase + " " + linkUrl);
}
} else {
Console.WriteLine(" " + response.ReasonPhrase + " " + linkUrl);
break;
}
}
}
Expand Down
Loading

0 comments on commit 3481a22

Please sign in to comment.