Could Not create ssl/tls secure channel. Html Agility

c# html-agility-pack web-scraping

Question

I am trying to scrape a site using HTML Agility Pack. The site is using https and it shows the error on this line

doc = web.Load(url);

I am creating a desktop application not a web application.

1
3
8/9/2017 9:57:46 AM

Accepted Answer

You need to enable the correct protocol type on the service point manager. Just add it before the line you said caused the error. This should do it.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
doc = web.Load(url);
6
8/10/2017 2:37:44 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow