Python SEO Bot: Your Gateway to Bing Submission Success!

Bing Submission use case.


In addition to described earlier IndexNow method to submit your URLs to Microsoft Bing search engine, you can also use Bing Submission API method. IndexNow is positioned modern and more advanced method, but Submission API from my point of view more stable and reliabla. For example sometimes you need to adjust sleep timer in a loop for IndexNow to be sure that all URLs to be delivered correctly, Submission API more stable according to my expirience.

Microsoft Bing Submission API bot with Python.
Microsoft Bing Submission bot meme.

Coding: The Silent Symphony. - Updated: 2024-06-14 by Andrey BRATUS, Senior Data Analyst.




The Python script below delivers URLs one-by-one in a loop, you can inprove it to change JSON payload from individaul "url" to list using "urlList" parameter. Before trying adjusting script for your need, don't forget to get the API key from Bing Webmaster Tools (the key in example below is changed).


How does the script works in simple words:

- Libraries import.
- Reading actual sitemap and creating dataframe with all URLs.
- Converting DF to list.
- Slicing the list to adjust it's size to correspond your quota if needed.
- Defining submission function - use your key !!!
- Magic: using FOR loop sending your URLs to BING.




# BING Submission API

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


# Constructing JSON payload from sitemap
sitemap_urls = adv.sitemap_to_df("https://weird-jokes.com/static/img/sitemap.xml")
url0 = sitemap_urls["loc"].to_list()
url=url0[2:100]

# URLs submission function
def get_(data):
    headers={'User-Agent':'curl/7.12.1 ',
             'Content-Type':'application/json'}
    try:
        r = requests.post(url='https://ssl.bing.com/webmaster/api.svc/json/SubmitUrl?apikey=536f58671234572dbe066b4aada63a62',json=data)
        print(r.status_code)
        print(r.content)
    except Exception.e:
        print(e)


# URLs submission in cycle
for i in url:

          my_json_payload={
                            "siteUrl": "https://weird-jokes.com/",
                            "url": i
                          }
          print(my_json_payload)
          get_(my_json_payload)                
          time.sleep(3)

print(len(url)) 
print('Thats all, folks !!!') 

If everything was OK, enjoy 200 response from BING.


Submission API output.





See also related topics: