4

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.

3
  • 2
    Adding the url (or a url with a similar error if you cannot provide the one you use) will probably help people to try it and see the error on their side. Aug 9, 2017 at 12:05
  • 1
    manta.com/c/mtxbllz/berbere-world-imports-inc Sorry here is the url
    – Faisal
    Aug 9, 2017 at 13:03
  • Did you find a solution for this problem? Thanks
    – AMINCHAR
    Sep 13, 2018 at 9:41

1 Answer 1

6

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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.