今日已更新 80 条资讯 | 累计 20052 条内容
关于我们

Boosting Blog Post Visibility: Building an Automation System with the IndexNow API

박준희 2026年06月07日 12:00 5 次阅读 来源:Dev.to

I'm sure many of you have experienced the frustration of publishing a new blog post only to find it's not immediately visible in search engine results. I recently learned that search engines like Bing and Yandex offer a way to quickly notify them of new posts via the IndexNow API. So, I decided to integrate this feature into my blog. Attempts and Pitfalls Initially, I created helper functions in services/indexnow_service.py to call the IndexNow API when a post was published. I structured the code to use asyncio.create_task to send a ping asynchronously whenever the post status changed to 'published' in the BlogRepository.update_status method. # services/indexnow_service.py (partial) import asyncio import httpx async def ping_urls ( urls : list [ str ], api_key : str ): async with httpx . AsyncClient () as client : for url in urls : try : response = await client . post ( " https://api.indexnow.org/submit-url " , json = { " url " : url , " key " : api_key } ) response . raise_for_status () print ( f " Successfully pinged { url } " ) except httpx . HTTPStatusError as e : print ( f " Error pinging { url } : { e } " ) except Exception as e : print ( f " An unexpected error occurred for { url } : { e } " ) async def ping_blog_post ( post_url : str , api_key : str ): await ping_urls ([ post_url ], api_key ) # BlogRepository.update_status (partial) async def update_status ( self , post_id : int , new_status : str ): # ... existing logic ... if new_status == ' published ' and INDEXNOW_KEY : post = await self . get_post_by_id ( post_id ) # In reality, you'd get the URL from the post object asyncio . create_task ( ping_blog_post ( post . url , INDEXNOW_KEY )) # ... I also created an admin API endpoint to manually trigger pings. I set up the public/<KEY>.txt file and even configured middleware. But to my surprise, the pings just wouldn't go through, no matter what I tried. After about three hours of debugging, I discovered that the ownership verification file required by the In

本文内容来源于互联网,版权归原作者所有
查看原文