Merge pull request #24 from carltibule/feature/AddUserAgentToWebClientBeforeDownloadingWebPageString

Fixed 403 Forbidden thrown when getting Website metadata
This commit is contained in:
Carl Tibule
2023-03-04 00:39:51 -06:00
committed by GitHub
5 changed files with 271 additions and 5 deletions

View File

@ -253,6 +253,7 @@ namespace YABA.Service
private void UpdateBookmarkWithMetaData(IBookmark bookmark)
{
var webClient = new WebClient();
webClient.Headers.Add("User-Agent", "APIClient");
var sourceData = webClient.DownloadString(bookmark.Url);
var title = Regex.Match(sourceData, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;
var description = string.Empty;