互联网技术 · 2024年2月12日

ASP.net实现百度主动推送功能的代码

百度站长工具的主动推送功能,以最为快速的提交方式,推荐您将站点当天新产出链接立即通过此方式推送给百度,以保证新链接可以及时被百度收录

官方提供了curl、post、php、ruby的实现示例,并没有C#的官方示例。既然提供了post的方式,那么就可以用C#实现,下面是实现代码:

ASP.net百度主动推送代码范例

public static string PostUrl(string[] urls)
    {
        try
        {
            string formUrl = “

http://data.zz.baidu.com/urls?site=www.yoursite.com&token=yourcode”;   

            string formData = “”;
    
            foreach (string url in urls)
            {
                formData += url + “n”;
            }
    
            byte[] postData = System.Text.Encoding.UTF8.GetBytes(formData);
    
            // 设置提交的相关参数 
      &

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册