相关疑难解决方法(0)

c#:将网页的html源码读入字符串

我希望能够使用winforms将某个网页的html源读入c#中的字符串

我该怎么做呢?

c#

11
推荐指数
2
解决办法
3万
查看次数

如何用HttpClient替换WebClient?

我的asp.net mvc Web应用程序中有以下WebClient:

using (WebClient wc = new WebClient()) // call the Third Party API to get the account id 
{
     string url = currentURL + "resources/" + ResourceID + "/accounts?AUTHTOKEN=" + pmtoken;
     var json = await wc.DownloadStringTaskAsync(url);
 }
Run Code Online (Sandbox Code Playgroud)

那么有人可以建议我如何将它从WebClient更改为HttpClient?

.net webclient webrequest webclient-download

6
推荐指数
1
解决办法
8447
查看次数

如何通过C#获取HTML页面源代码

我想保存在本地驱动器上完整的网页ASP .htmURL链接,但我没有成功。

public StreamReader Fn_DownloadWebPageComplete(string link_Pagesource)
{
     //--------- Download Complete ------------------
     //  using (WebClient client = new WebClient()) // WebClient class inherits IDisposable
     //   {

     //client
     //HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(link_Pagesource);

                    //webRequest.AllowAutoRedirect = true;
                    //var client1 = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(link_Pagesource);
                    //client1.CookieContainer = new System.Net.CookieContainer();


                 //   client.DownloadFile(link_Pagesource, @"D:\S1.htm");

              //  }
         //--------- Download Page Source ------------------
 HttpWebRequest URL_pageSource = (HttpWebRequest)WebRequest.Create("https://www.digikala.com");

                    URL_pageSource.Timeout = 360000;
                    //URL_pageSource.Timeout = 1000000;
                    URL_pageSource.ReadWriteTimeout = 360000;
                   // URL_pageSource.ReadWriteTimeout = 1000000;
                    URL_pageSource.AllowAutoRedirect = true;
                    URL_pageSource.MaximumAutomaticRedirections = 300; …
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
1
解决办法
8219
查看次数

如何打开Internet Explorer窗口,在URL上导航并使用c#和mshtml库获取她的文档(HTMLDocument或InternetExplorer)

如何打开Internet Explorer窗口或选项卡,导航它并使用c#和mshtml库获取她的文档(HTMLDocument或InternetExplorer).IE对象的类型应该是HTMLDocument或InternetExplorer.

c# internet-explorer mshtml

1
推荐指数
1
解决办法
4748
查看次数