I am trying to scrape a webpage when it throws a "potentially dangerous script" error. Everytime I do this, I get a server 500 but I can scrape a normal, operating page. Is there a way I can scrape a webpage when it throws an error?
Thanks
I am trying to scrape a webpage when it throws a "potentially dangerous script" error. Everytime I do this, I get a server 500 but I can scrape a normal, operating page. Is there a way I can scrape a webpage when it throws an error?
Thanks
Just a guess, but maybe the error thrown, triggers a server error (500)? That would make sense. You should be still able to get the output from the page.
Generally though, and I hope you don't mind, I'd have to object to your error handling. First off, you could put the error in a log and use a tool to monitor it for errors. Secondly, if your script throws an exception, you could hand it off to a service like Exceptional, which in turn notifies you.
Why not use ASP.NET health monitoring? There's a mail provider that will automatically send the error details to you without any manual scraping and you can configure it all with just some config file entries. Easy!
Consider using ELMAH to log all errors. You'll get lots of useful additional information also.
More details at:
http://msdn.microsoft.com/en-us/library/aa479332.aspx http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx