3

I'm using SHDocVw.InternetExplorerClass to scrape a webpage. It works fine in XP, but when I try to run it in windows 7 I get an error:

The interface is unknown. (Exception from HRESULT: 0x800706B5)

When I run visual studio in administrator mode it works fine, but the published application has to be run in administrator mode too, which isn't acceptable.

Is there any way to get around running the application in administrator mode?

AndyD273
  • 7,177
  • 12
  • 54
  • 92

1 Answers1

2

Do you absoltely need to use SHDocVw.InternetExplorerClass for scraping? Can you just send regular HTTP web requests using System.Net.WebClient or HttpWebRequest? These are the preferred ways. You generally should only use SHDocVw.InternetExplorerClass for scraping if you need to execute scripting technologies like JavaScript or VBScript.

Chris Haas
  • 53,986
  • 12
  • 141
  • 274
  • I'd love to avoid using it, but the data is behind a login screen with cookies and stuff, and so far I haven't found a way to get directly to the page without scripting the whole login process. We have another webpage where we use clients credentials to login to do some stuff for them. There are 50-60 usernames/passwords to remember, and so we have an app that opens IE, and puts in the correct username/password so that people don't have to look it all up in an excel file or something. They just double click on the client and the app logs them in. – AndyD273 Jun 15 '11 at 12:32
  • For usernames and passwords you just need to send those as variables over POST (or GET for a really insecure site). Then with a webclient you just need to amend it to store cookies. There's a bunch of samples on this site that show you how to do that. – Chris Haas Jun 15 '11 at 14:16
  • I've played around with that stuff a bit, but it is a very secure site, and the whole post/cookie thing has me stumped. Assuming that my second example is the norm (remote controlling IE in order to avoid having to look up that stuff from a long list) how would I avoid having to run as administrator? I love that Windows 7 is more secure, but it annoys me when stuff like this comes up. I probably will still give `WebClient` another look, but it won't completely solve my problem. – AndyD273 Jun 15 '11 at 20:16
  • How about just using the standard `WebBrowser` control then? I can't test from here but I can't imagine that it needs admin elevation. As for being a "very secure site", it all comes down to text at a certain point. You send text to the server, it send it back to you. Watch what happens in fiddler or something else and you'll learn that its pretty easy to mimic. – Chris Haas Jun 15 '11 at 20:31
  • Hadn't heard of fiddler before, I will look into it. I was hoping to keep using IE since it then can be a stand alone window. And it's what they are used to, but I'll give it a try. – AndyD273 Jun 15 '11 at 20:44