c# 获取百度最后的url

mac2022-06-30  23

 

using System;using System.Collections.Generic;using System.Linq;using System.Net.Http;using System.Text;using System.Threading.Tasks;

 

namespace getBaiDuUrl{ class Program { static void Main(string[] args) { string LastAdurl= GetLocation("http://www.baidu.com/link?url=MW4aqBcVd9VSAsqrVcG8lMzlHUU1qWjFsD_PxZNEjJlxE1sNpirSITeWwcBgcGQ8"); } public static string GetLocation(string URL) { HttpClientHandler hander = new HttpClientHandler(); hander.AllowAutoRedirect = false; HttpClient client = new HttpClient(hander); return client.GetAsync(URL).Result.Headers.Location.ToString(); } }}

 

转载于:https://www.cnblogs.com/c-x-a/p/7232154.html

最新回复(0)