简体   繁体   English

使用WebClient c#

[英]Using WebClient c#

I have seen some links that tells how to use web client but one thing is still un clear to me as i am not sharp developer. 我已经看到了一些链接,告诉我们如何使用Web客户端,但有一点我还不清楚,因为我不是敏锐的开发人员。

  1. Dose this implements POST 剂量这实现了POST
  2. Difference between HttpWebRequest HttpWebRequest之间的区别
  3. How to determine Fields from page source in which values are to be placed 如何从页面源中确定要放置值的字段
  4. How values should be placed 如何放置价值观

I studied http://www.daveamenta.com/tag/webclient/ 我读过http://www.daveamenta.com/tag/webclient/

It would be great if some one gives an example of html feilds and how to use them in web client 如果有人提供html领域的例子以及如何在Web客户端中使用它们会很棒

Does this implements POST 这是否实现了POST

Yes, you can use the UploadString , UploadData , and UploadValues methods 是的,您可以使用UploadStringUploadDataUploadValues方法

Difference between HttpWebRequest HttpWebRequest之间的区别

Basically, WebClient is just a wrapper for WebRequest ( FtpWebRequest , HttpWebRequest ...), to make it easier to use. 基本上, WebClient只是WebRequestFtpWebRequestHttpWebRequest ...)的包装器,使其更易于使用。 It doesn't give you as much control, but it's enough for simple scenarios 它没有给你那么多的控制权,但它对于简单的场景来说已经足够了

How to determine Fields from page source in which values are to be placed 如何从页面源中确定要放置值的字段

I don't really understand what you mean... 我真的不明白你的意思......

How values should be placed 如何放置价值观

Are you talking about form fields? 你在谈论表格领域吗? You can use the UploadValues method, which does the same as submitting an HTML form with POST 您可以使用UploadValues方法,该方法与使用POST提交HTML表单相同

MSDN is the best place to get exact answers for .Net stuff. MSDN是获取.Net内容的确切答案的最佳位置。

Here's an article on WebClient versus HttpWebRequest. 这是一篇关于WebClient与HttpWebRequest的文章。 Basically WebClient is designed to be quick and easy. 基本上,WebClient设计简单快捷。 HttpWebRequest is more complex, but more powerful. HttpWebRequest更复杂,但功能更强大。

http://blogs.msdn.com/b/silverlight_sdk/archive/2008/04/01/using-webclient-and-httpwebrequest.aspx http://blogs.msdn.com/b/silverlight_sdk/archive/2008/04/01/using-webclient-and-httpwebrequest.aspx

There has also been lengthy discussion on this topic on SO before: 在此之前,关于此主题的讨论也很长:

WebClient vs. HttpWebRequest/HttpWebResponse WebClient与HttpWebRequest / HttpWebResponse

webclient is a simple way to get the content from web-page something like webclient是一种从网页获取内容的简单方法

webclient client= new webclient();
string content = client.downloadstring('google'.com');

for downloading the page using webclient is simple but using httprequest difficult. 使用webclient下载页面很简单,但使用httprequest很困难。

simple thing can be done by webclient without write many line of code. 简单的事情可以通过webclient完成而无需编写多行代码。

but many hard not yet possible in webclient. 但在webclient中还有很多难以实现的功能。

so simply HttpWebRequest is better option then webclient. 所以简单的HttpWebRequest比webclient更好。

see here a little example 看到这里的一个小例子

http://geekswithblogs.net/anirudha/archive/2010/07/25/parsing-text-in-c-sharp.aspx http://geekswithblogs.net/anirudha/archive/2010/07/25/parsing-text-in-c-sharp.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM