Ok so will keep straight forward and simple. I am doing some web scraping and want to make it so a user can enter a site. This is not the point; the point is if I do this to give my website a actual site mywebsite.load("websiteURLhere") then if the website is not correct it will give me a UriFormatException. So I want to be able to have an if statement that somehow checks for if I receive an UriForamtException then to tell the user that the url is not correct, or just to revert so something else. I know I could use a try catch statement in c# but I just don't want to. Will include some code down below. I am using HTML Agility Pack as the library for web scraping.
I have looked through other peoples code but not many seem to be putting emphasis on error handling in this way. IG this is intended for when you know the specific site but I would love to know what I should use or research to error handle this boi.
loading website and storing it in document:
Error I get when URL is not a website (target website is a random string this instance):
Any suggestions for error checking would be great. I have to still use Html Agility Pack though. I really appreciate anyone to takes their time to help me with this thanks. If anyone needs any clarification then comment and I will answer.
Aucun commentaire:
Enregistrer un commentaire