コード例 #1
0
        private async Task <string> GetHtmlAsync(string url)
        {
            var fileName  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PhantomJS", "phantomjs.exe");
            var arguments = ".\\PhantomJS\\_ReqHtml.js " + url;

            return(await ProcessHelper.Action(fileName, arguments));
        }
コード例 #2
0
        public async Task <string> GetRealAddressAsync(string address)
        {
            try
            {
                HttpClient          client   = new HttpClient();
                HttpRequestMessage  request  = new HttpRequestMessage(HttpMethod.Head, address);
                HttpResponseMessage response = await client.SendAsync(request);

                if (response.StatusCode == System.Net.HttpStatusCode.Found)
                {
                    return(response.Headers.Location.AbsoluteUri);
                }
                else
                {
                    return(response.RequestMessage.RequestUri.AbsoluteUri);
                }
            }
            catch
            {
                var fileName  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PhantomJS", "phantomjs.exe");
                var arguments = ".\\PhantomJS\\_ReqUrl.js " + address;
                return(await ProcessHelper.Action(fileName, arguments));
            }
        }