Greetings all
Does anyone know how to fetch the file name list of api results as below, by using HttpWebRequest via C#? Thank you in advance!
Greetings all
Does anyone know how to fetch the file name list of api results as below, by using HttpWebRequest via C#? Thank you in advance!
You can use FtpWebRequset to get the list of files in api-results directory. The snippet code is:
using System; using System.Net; using System.IO; namespace FTPWebRequest { class Program { static void Main(string[] args) { FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://tickhistory-ftp.thomsonreuters.com/api-results"); request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; // This example assumes the FTP site uses anonymous logon. request.Credentials = new NetworkCredential("Username", "Password"); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription); reader.Close(); response.Close(); } } }
I go this code from https://msdn.microsoft.com/en-us/library/ms229716(v=vs.110).aspx.
I do not know if you can do this using the current TRTH SOAP API.
But it will be possible with the TRTH REST API, for requests made using the REST API. The TRTH REST API is currently in EAP.
Thank you Christiaan, I will check HOW REST API works.
But sadly, client is using the SOAP API, so I have to find out a way to resolve this..
This is how I sort it out
// 设置参数 HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; //发送请求并获取相应回应数据 HttpWebResponse response = request.GetResponse() as HttpWebResponse; //直到request.GetResponse()程序才开始向目标网页发送Post请求 Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); //Output string data = reader.ReadToEnd(); MatchCollection matches = Regex.Matches(data, "<a(?:\\s+.+?)*?\\s+href=\"([^\"]*?)\".+>(.*?)</a>", RegexOptions.IgnoreCase); List<string> mList = new List<string>(); foreach (Match match in matches) { string s = match.Groups[1].Value; Console.WriteLine(s); mList.Add(s); }