c# 获取百度最后的url
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();
}
}
}