zl程序教程

您现在的位置是:首页 >  后端

当前栏目

c# 获取百度最后的url

c#百度 获取 url 最后
2023-09-14 09:06:38 时间

 

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();
}
}
}