开发者

.NET Web Scripting

开发者 https://www.devze.com 2022-12-12 03:43 出处:网络
I\'m attempting to right a script to logon (username and password) on to a website and download a file. I\'ve tried using the webClient and开发者_开发知识库 webBrowser classes to no avail, they don\'t

I'm attempting to right a script to logon (username and password) on to a website and download a file. I've tried using the webClient and开发者_开发知识库 webBrowser classes to no avail, they don't seem to work for what I need them to do.

Does anyone else have any suggestions?


I'd suggest you look at this StackOverflow thread. This is not specific to any programming language or platform (you didn't mention which language/platform you're using, so I can't offer any specific code advice) but in my answer I detail the basic approach you'll need to take for successful HTML screen-scraping.

In a nutshell, first you'll need to the right combination of HTTP headers, URLs, and POST data to fool the server into thinking your client app is a "real" browser. A tool like Fiddler which allows you to see actual HTTP requests going over the wire, and experimentally build new requests based on browser requests, is invaluable here.

Next you'll need to figure out, in your language and platform, how to produce that set of headers, URLs, and/or POST data. Typically, handling cookies and redirects are the hardest-- and most platforms have specialized classes (e.g. CookieContainer in .NET) to help with things like this.

0

精彩评论

暂无评论...
验证码 换一张
取 消