Rank: Advanced Member Groups: Member
Joined: 9/20/2016 Posts: 73
|
Hello! Is there a way to directly and silently download a file (without dialogs) using webview and get binary data? Tried this with no luck:
EO.WebBrowser.WebView m_WebView = new EO.WebBrowser.WebView(); m_WebView.LoadHtmlAndWait(mp3link); var aaa = m_WebView.GetHtml();
Or maybe better to use HttpWebRequest for this purpose?
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, First you need to use a ThreadRunner when you try to create a WebView without UI: https://www.essentialobjects.com/doc/webbrowser/start/webview_no_ui.aspxNext if you just want it to download a file (instead of rendering it and downloading it), you will need to use our downloading interface: https://www.essentialobjects.com/doc/webbrowser/customize/download.aspxHope this helps. Please feel free to let us know if you still have any more questions. Thanks!
|
Rank: Advanced Member Groups: Member
Joined: 9/20/2016 Posts: 73
|
Thank you for the answer! I've already used HttpWebRequest. I need to load small files, and i think it's a faster way:
public byte[] getDataFromUrl(string url) { System.Net.HttpWebRequest request = null; System.Net.HttpWebResponse response = null; byte[] b = null; request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); response = (System.Net.HttpWebResponse)request.GetResponse(); if (request.HaveResponse) { if (response.StatusCode == System.Net.HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); using (BinaryReader br = new BinaryReader(receiveStream)) { b = br.ReadBytes(500000); br.Close(); } } } return b; }
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Yes. If you just want to download the file out right then you do not need a browser engine since the main purpose of the browser engine is to interpret, run and render the page. In some occasions you may need those features in order to properly download a file (for example, if you must go through a login page first), then you can use the browser engine to automate such task.
Thanks!
|