webclient

Powershell - Download Image from an image url

天大地大妈咪最大 提交于 2019-12-07 13:17:08
问题 limited knowledge with powershell. I try to download a image from an image url. for example like this : "http://hdwallpaperia.com/wp-content/uploads/2014/01/Mc-Laren-P1-Wallpaper-Image-Picture-640x360.jpg" Before to reach the link, I have to login first. here is My login page html code: <tr> <td colspan="2">Please enter your user name and password below:</td> </tr> <tr style="height: 10px;"><td></td></tr> <tr> <td>User Name:</td> <td><input name="login_username" style="width: 295px;" type=

How to enter password automatically in Webview

落爺英雄遲暮 提交于 2019-12-07 10:32:57
问题 I am new to Java and Android and I got a question. I think the solution is maybe very easy but I couldn't solve it. I created an application with a WebView the thing is I want that the webview enters username and password automatically so that the user is already logged in when he starts the application. I googled it and found something like that but it does not work @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

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

Is it safe to use the same CookieContainer across multiple HttpWebRequests?

房东的猫 提交于 2019-12-07 07:49:42
问题 I am doing a kind of WebCrawler and I need to persist the Cookies state between requests. I download all pages async creating new HttpWebRequest instances, but setting the same CookieContainer. The pages can write and read cookies. Can I do it safely? There is any alternative that isn´t subclass the CookieContainer and put locks at all method? The MSDN says that this class isn´t thread safe, but in practice, can I do it? 回答1: According to the documentation: Any public static (Shared in Visual

Mono WebClient encoding issue

余生颓废 提交于 2019-12-07 07:31:10
问题 I'm trying to port a .NET application from Windows to Mono, but certain code that was working on Windows is no longer working ( as expected ) on mono : WebClient client = new WebClient (); Console.WriteLine (client.DownloadString("http://www.maxima.fm/51Chart/")); it seems to detect correctly the encoding as UTF-8 (and manually setting the encoding to UTF-8 or ASCII don't work either) there are still '?' characters 回答1: You are writing to the console. Maybe your console is not configured

Downloading .csv file from Google Trends

ぐ巨炮叔叔 提交于 2019-12-07 05:49:48
问题 I'm looking to download Google Trends data from URLs that I create via code. These URLs, when put into the browser (I use firefox) show a save prompt where I can choose to open or save the file when looking through the browser. However, I am hoping to the the same .csv file containing the Google Trends data via code, and I am stuck. Here is one of the links that my code creates: [Does prompt to download, however is is Google] https://www.google.com/trends/trendsReport?hl=en-US&q=debt&geo=US

Uploading files to file server

北城余情 提交于 2019-12-07 05:33:23
Using the link below, I wrote a code for my application. I am not able to get it right though, Please refer the link and help me ot with it... Uploading files to file server using webclient class The following is my code:- protected void Button1_Click(object sender, EventArgs e) { filePath = FileUpload1.FileName; try { WebClient client = new WebClient(); NetworkCredential nc = new NetworkCredential(uName, password); Uri addy = new Uri("\\\\192.168.1.3\\upload\\"); client.Credentials = nc; byte[] arrReturn = client.UploadFile(addy, filePath); Console.WriteLine(arrReturn.ToString()); } catch

How to read an ASP.NET internal server error description with .NET?

半腔热情 提交于 2019-12-07 04:47:10
问题 Behold the code: using (var client = new WebClient()) { try { var bytesReceived = client.UploadData("http://localhost", bytesToPost); var response = client.Encoding.GetString(bytesReceived); } catch (Exception ex) { } } I am getting this HTTP 500 internal server error when the UploadData method is called. But I can't see the error description anywhere in the "ex" object while debugging. How do I rewrite this code so I can read the error description? 回答1: Web servers often return an error page

WebClient DownloadString UTF-8 not displaying international characters

杀马特。学长 韩版系。学妹 提交于 2019-12-07 03:05:38
问题 I attempt to save the html of a website in a string. The website has international characters (ę, ś, ć, ...) and they are not being saved to the string even though I set the encoding to be UTF-8 which corresponds to the websites charset. Here is my code: using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; string htmlCode = client.DownloadString(http://www.filmweb.pl/Mroczne.Widmo); } When I print "htmlCode" to the console, the international characters are not shown

How can I get WebClient (webservice client) to automatically use the default proxy server?

雨燕双飞 提交于 2019-12-06 21:18:52
问题 I'm calling a webservice from a WinForms app. Everything works fine when a proxy server isn't in use, however when a proxy is being used, the app crashes as instead of the XML response it's expecting for the SOAP request, it gets an HTML error page saying "Authentication Required". It seems you can set the proxy manually like this: WebClient client = new WebClient(); WebProxy wp = new WebProxy("proxy server url here"); client.Proxy = wp; ...but to some extent, it seems to be seeing the proxy