zzzprojects / html-agility-pack

Html Agility Pack (HAP) is a free and open-source HTML parser written in C# to read/write DOM and supports plain XPATH or XSLT. It is a .NET code library that allows you to parse "out of the web" HTML files.
https://html-agility-pack.net
MIT License
2.64k stars 375 forks source link

When using LoadFromBrowser, a popup window appears if the content is in json. #457

Closed ogosengi closed 2 years ago

ogosengi commented 2 years ago

When using LoadFromBrowser, a popup window appears if the content is in json. Can I disable the pop-up window? Language: C# HtmlAgilityPack ver: 1.11.38 Point of Popup

HtmlAgilityPack.HtmlDocument doc = web.LoadFromBrowser(strurl);

json

JonathanMagnan commented 2 years ago

Hello @ogosengi ,

Thank you for reporting, we will look at it.

Best Regards,

Jon


Sponsorship Help us improve this library

Performance Libraries context.BulkInsert(list, options => options.BatchSize = 1000); Entity Framework ExtensionsBulk OperationsDapper Plus

Runtime Evaluation Eval.Execute("x + y", new {x = 1, y = 2}); // return 3 C# Eval FunctionSQL Eval Function

JonathanMagnan commented 2 years ago

Hello @ogosengi ,

The v1.11.39 has been released.

Could you try it and let me know if everything is fixed


Is this library useful to you? Please help us by becoming a sponsor to keep it alive and supported.

ogosengi commented 2 years ago

Thank you for Your fast reply. But It hasn't been fixed yet.

I am coding in VisualStudio2019(WindowsForm, .NET Framework 4.7.2) example code: string str1 = "https://infuser.odcloud.kr/oas/docs?namespace=15074473/v1"; HtmlWeb web = new HtmlWeb(); HtmlAgilityPack.HtmlDocument doc = web.LoadFromBrowser(str1);

The pop-up window still appears.

JonathanMagnan commented 2 years ago

Hello @ogosengi ,

Unfortunately, I don't get a popup anymore on my side even with the URL and config you provided. So that makes it pretty much impossible to fix it on my side.

Could you check if you still get the popup with this code:

string str1 = "https://infuser.odcloud.kr/oas/docs?namespace=15074473/v1";

var webBrowser = new WebBrowser();
webBrowser.ScriptErrorsSuppressed = true;
webBrowser.NewWindow += WebBrowser_NewWindow;
webBrowser.Navigate(str1);

private void WebBrowser_NewWindow(object sender, CancelEventArgs e)
{
    e.Cancel = true;
}

If yes, try to fix it if you can and we will apply your change. As said, we cannot reproduce it so we cannot go anything more on our side.

Best Regards,

Jon

ogosengi commented 2 years ago

Hello @JonathanMagnan

It is same problem. From googling, It seems that it is probably a problem with IE Setting on my computer. Perhaps htmlagilityPack was made based on IE.

If I try the URL in IE, it will try to download the file in the same way. json2

I Try Selenium Chrome Driver (very slow ㅜㅜ)

private void button2_Click(object sender, EventArgs e) { ChromeOptions options = new ChromeOptions(); ChromeDriverService driverService = ChromeDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true;

options.AddArgument("headless");  
ChromeDriver driver = new ChromeDriver(driverService, options);

driver.Navigate().GoToUrl("https://infuser.odcloud.kr/oas/docs?namespace=15074473/v1");
textBox1.Text = driver.PageSource;

}

It is not Popup

JonathanMagnan commented 2 years ago

Hello @ogosengi ,

Unfortunately, we cannot add a reference to selenium to our project.

ogosengi commented 2 years ago

I solved it in another way. https://stackoverflow.com/questions/6114360/ie-prompts-to-open-or-save-json-result-from-server

I try Registry Update, It work.

JSON mime type


Windows Registry Editor Version 5.00 ; ; Tell IE to open JSON documents in the browser (rather than always demanding that it saves ; the JSON data into an external file first).
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place" . ; ; Taken from: ; http://stackoverflow.com/questions/2483771/how-can-i-convince-ie-to-simply-display-application-json-rather-than-offer-to-do

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json] "CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}" "Encoding"=hex:08,00,00,00

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\text/json] "CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}" "Encoding"=hex:08,00,00,00

tewuapple commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,你的邮件已收到。 亮亮