Python Bot + Bing IndexNow API = Microsoft Search Engine Success!

Bing IndexNow use case.


If you are a webmaster, URL submission to search engines is important part of your everyday activities. The script below submits all URLs of your site in one shot to Microsoft BING using IndexNow.

Microsoft Bing IndexNow bot with Python.



Normally from web interface, Webmasters tools, BINGs limits pages submission to 100 or 10 a day, so Python solution below is nice to have use case.


How does it works in simple words:

- Libraries import.
- Reading actual sitemap and creating dataframe with all URLs.
- Assigning your key and key file path (get them from IndexNow, it's easy).
- Converting DF to list.
- Magic: using FOR loop sending your URLs to BING.




import advertools as adv
import pandas as pd
import requests
import json
import time

sitemap_urls = adv.sitemap_to_df("https://python-code.pro/static/img/sitemap.xml")


# use your own key, key below was corrected
key = "s4dc7fc3ca124fea8b8a0f7e5982f56a"
url = sitemap_urls["loc"].to_list()
location = "https://python-code.pro/246c7fc3ca124fea8b8a0f7e5982f56a.txt"

for i in url:
          endpoint = f"https://bing.com/indexnow?url={i}&key={key}&keyLocation={location}"
          reaction = requests.get(endpoint)
          print(i)
          print(endpoint)
          print(reaction.status_code)
          time.sleep(3)


If everything was OK, enjoy 200 response from BING.

Hint #1: switch off VPN before script execution, you might get proxy error.
Hint #2: avoid URL spamming, do not run script too often, might cause website ranking problems.


IndexNow Microsoft Bing bot output





See also related topics: