diff --git a/StockScraper/StockScraper.Tests/StockScraperIntegrationTests.cs b/StockScraper/StockScraper.Tests/StockScraperIntegrationTests.cs index b9945c3..557dd72 100644 --- a/StockScraper/StockScraper.Tests/StockScraperIntegrationTests.cs +++ b/StockScraper/StockScraper.Tests/StockScraperIntegrationTests.cs @@ -9,8 +9,7 @@ public class StockScraperIntegrationTests public async Task GetHTML_ValidTicker_ReturnsNonNullData() { // arrange - // var ticker = "ES3.SI"; - var ticker = "O39.SI"; + var ticker = "ES3.SI"; // act var result = await Scraper.GetHTML(ticker); diff --git a/StockScraper/StockScraper/Scraper.cs b/StockScraper/StockScraper/Scraper.cs index cdf1c3b..ea7f061 100644 --- a/StockScraper/StockScraper/Scraper.cs +++ b/StockScraper/StockScraper/Scraper.cs @@ -3,6 +3,7 @@ using ExcelDna.Integration; using ExcelDna.Registration; using System; +using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; @@ -85,8 +86,9 @@ public static async Task bdp( internal static async Task> GetHTML(string ticker) { var quoteSummary = new Dictionary(); - var config = Configuration.Default.WithDefaultLoader(); - // new DefaultHttpRequester { Headers = { ["User-Agent"] = USER_AGENT } } + var htmlRequestor = new DefaultHttpRequester(); + htmlRequestor.Headers["User-Agent"] = USER_AGENT; + var config = Configuration.Default.With(htmlRequestor).WithDefaultLoader(); var context = BrowsingContext.New(config); var tickerUC = ticker.ToUpper(); var document = await context.OpenAsync($"https://sg.finance.yahoo.com/quote/{tickerUC}/"); diff --git a/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn-packed.xll b/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn-packed.xll index e7197b4..89453fc 100644 Binary files a/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn-packed.xll and b/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn-packed.xll differ diff --git a/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn64-packed.xll b/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn64-packed.xll index 2796643..d0f35cc 100644 Binary files a/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn64-packed.xll and b/StockScraper/StockScraper/bin/Debug/StockScraper-AddIn64-packed.xll differ