Downloading Entire Webpage Content

Created at 28 Jun 2024, 05:11
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NT

nthanhkieuvps

Joined 28.06.2024

Downloading Entire Webpage Content
28 Jun 2024, 05:11


Thank you for your seeing
I am currently working on an algorithm using cTrader, and I have encountered an issue that I am hoping you could assist me with. The objective of my algo is to download the entire content of a webpage. However, I am experiencing difficulties in achieving this. It appears that the algo is not able to retrieve the full content of the webpage as intended.

I have attached the program for your reference. Could you please review it and provide guidance or recommendations on how to successfully download the complete content of a webpage using a cTrader algo? Are there specific methods or best practices that I should follow to accomplish this task?

Thank you in advance for your assistance and support.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; using System.Net.Http; using System.Net.Http.Json;

namespace cAlgo.Robots {    [Robot(AccessRights = AccessRights.FullAccess)]    public class NewcBot6 : Robot    {        readonly HttpClient client = new HttpClient();

protected override void OnStart()        {           string LinkDowload = "https://www.forexfactory.com/calendar";         HttpResponseMessage responseToGet = client.GetAsync(LinkDowload).Result;         var stream = responseToGet.Content.ReadAsStream();         var reader = new StreamReader(stream);         string LichKT = reader.ReadToEnd();

string TenFileLuu = SymbolName+".txt";            using (var responseReader = new StreamReader(stream))            {                    using (var writer = new StreamWriter(TenFileLuu))                {                writer.Write(LichKT);                }            }        }        protected override void OnTick()   
     {

}
}
}


@nthanhkieuvps
Replies

firemyst
28 Jun 2024, 07:07 ( Updated at: 28 Jun 2024, 07:16 )

Have you reviewed and tried the example Spotware provided?

 

https://help.ctrader.com/ctrader-algo/guides/network-access/#how-to-use-network-access

 

If so, what happened?


@firemyst