downloadstring

Multi-language Google Translate API is returing (503) Server Unavailable

◇◆丶佛笑我妖孽 提交于 2019-12-10 09:47:07
问题 I am trying to use Google Translate to translate but it gives error Server Unavailable. What my guess is that when I try to put same thing in the address bar we receive a captcha to fill in. If we get thru the captcha than only it downloads a txt file. I am thinking this might be the issue of captcha page and not the Server Unavailable. Calling Function. string result = TranslateGoogle("Life is great and one is spoiled when it goes on and on and on", "en", "hi"); Console.WriteLine(result);

WebClient DownloadString not returning anything

白昼怎懂夜的黑 提交于 2019-12-08 19:55:36
问题 I want to get the source code from a Search query of Pirate Bay, I have this in my code but it doesn't return anything: WebClient webpage = new WebClient(); string source= webpage.DownloadString("http://thepiratebay.sx/search/documentary/0/99/0"); 回答1: Here's a quick test: xaml: <Label Content="{Binding ElementName=window_name, Path=SourceTest}"></Label> <Label Content="{Binding ElementName=window_name, Path=SourceTest2}"></Label> Code: string source_url = "http://thepiratebay.sx/search

WebClient download string (a few chars page) is so slow

 ̄綄美尐妖づ 提交于 2019-12-07 08:00:44
问题 I am trying to download a string from an URL. Unfortunately, it is very slow. Here is my code: // One of these types for two bad solutions anyway // byte[] result = new byte[12]; // string result; using (var webClient = new System.Net.WebClient()) { String url = "http://bg2.cba.pl/realmIP.txt"; //result = webClient.DownloadString(url); // slow as hell //webClient.OpenRead(url).Read(result, 0, 12); // even slower } It takes about 4-5 seconds, which seems very inappropriate to me... Content of

WebClient download string (a few chars page) is so slow

老子叫甜甜 提交于 2019-12-05 12:00:19
I am trying to download a string from an URL. Unfortunately, it is very slow. Here is my code: // One of these types for two bad solutions anyway // byte[] result = new byte[12]; // string result; using (var webClient = new System.Net.WebClient()) { String url = "http://bg2.cba.pl/realmIP.txt"; //result = webClient.DownloadString(url); // slow as hell //webClient.OpenRead(url).Read(result, 0, 12); // even slower } It takes about 4-5 seconds, which seems very inappropriate to me... Content of this url is IP XX.YYY.ZZ.FF Fixed, sorry for putting this question here I guess, but... here is working

How to limit the time DownloadString(url) allowed by 500 milliseconds?

情到浓时终转凉″ 提交于 2019-12-04 00:07:19
问题 I'm writing a program that when textBox1 change: URL = "http://example.com/something/"; URL += System.Web.HttpUtility.UrlEncode(textBox1.Text); s = new System.Net.WebClient().DownloadString(URL); I want limit the time DownloadString(URL) allowed by 500 milliseconds. If more than, cancel it. 回答1: There is no such property, but you can easily extend the WebClient : public class TimedWebClient: WebClient { // Timeout in milliseconds, default = 600,000 msec public int Timeout { get; set; } public

WebClient.DownloadString result is not match with Browser result 2

只愿长相守 提交于 2019-12-02 04:11:53
The following code: WebClient wc = new WebClient(); wc.Encoding = Encoding.UTF8; string Url = "http://www.tsetmc.com/tsev2/data/instinfodata.aspx?i=59266699437480384&c=64"; return wc.DownloadString(Url); code returns: �Q�T�MP�J�A|�^D����~���C�"�����l� ��;I&3=j=�iG�H9Ȓ�J�^� �j��T�Q=HH�'Qm�������1�hF�4�*�������{�x�\o? when I visit that URL in any web browser, I get: 12:29:45,A ,3540,3567,3600,3621,3690,3515,140,238204,849582597,1,20140914,122945;;1@2825@3523@3583@1700@1,1@2000@3522@3600@8700@2,1@500@3511@3640@2500@1,;19774,99736,1 is there any way to get right string? also, I use this online

How can I do System.Web.Script.Serialization in C#?

亡梦爱人 提交于 2019-12-01 15:05:00
How can I do this in C# modern UI ? var url = "http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0"; var wc = new WebClient(); var rawFeedData = wc.DownloadString(url); //You can use System.Web.Script.Serialization if you don't want to use Json.NET JavaScriptSerializer ser = new JavaScriptSerializer(); FeedApiResult foo = ser.Deserialize<FeedApiResult>(rawFeedData); //Json.NET also return you the same strong typed object var apiResult = JsonConvert.DeserializeObject<FeedApiResult>(rawFeedData); It gives me error an error in WebClient and

How can I do System.Web.Script.Serialization in C#?

≯℡__Kan透↙ 提交于 2019-12-01 13:56:51
问题 How can I do this in C# modern UI ? var url = "http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0"; var wc = new WebClient(); var rawFeedData = wc.DownloadString(url); //You can use System.Web.Script.Serialization if you don't want to use Json.NET JavaScriptSerializer ser = new JavaScriptSerializer(); FeedApiResult foo = ser.Deserialize<FeedApiResult>(rawFeedData); //Json.NET also return you the same strong typed object var apiResult =

Unparseable StackExchange API response

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 01:22:44
问题 I've written a small program to analyze my profile data from the StackExchange API, but the api returns unparse-/unreadable data to me. Data received: (self downloaded using c#) \u001f�\b\0\0\0\0\0\u0004\0mRMo�0\f�/:�d$�c˱�'�^{/\u0006��\u0018G�>\I��\u0015���\u0004݀�D>�GR�L'���o��\u0004�G���%JP\u001c����-��Em>0���X�bm~�\u0018tk��\u0014�M]r�dLG�v0~Fj=���1\u00031I�>kTRA\"(/+.����;Nl\u0018�?h�\u0014��P藄�X�aL��w���#�3\u0002��+�\u007f���\u0010���\u000f�p�]��v\u007f���\t��ڧ�\nf��״\u0018\u0014eƺ�_�

DownloadStringAsync wait for request completion

戏子无情 提交于 2019-11-28 10:59:14
I am using this code to retrieve an url content: private ArrayList request(string query) { ArrayList parsed_output = new ArrayList(); string url = string.Format( "http://url.com/?query={0}", Uri.EscapeDataString(query)); Uri uri = new Uri(url); using (WebClient client = new WebClient()) { client.DownloadStringAsync(uri); } // how to wait for DownloadStringAsync to finish and return ArrayList } I want to use DownloadStringAsync because DownloadString hangs the app GUI, but I want to be able to return the result on request . How can I wait until DownloadStringAsync finish the request? why would