Automate Blog Post creation using Blogger APIs and Python

This article will discuss the following topics,

  • Blogger's REST APIs.
  • Google's OAuth 2.0 playground.
  • Accessing spreadsheet in Python.
  • Creating blogger posts via Python.

An experiment to automate blog post creation when you have structured data.

I was searching for IFSC codes for some bank transactions and came across Reserve Bank's website, which has a list of Excel files containing Bank Codes, Contact Info and related details of each bank's branch. This time I will be looking towards Bharat co-operative bank of Mumbai. Here is how the corresponding data looks like.


In the above picture, each row represents lots of details about each branch of the Bank. Let's think of creating a list of blog posts where each post gives IFSC codes of a particular branch along with address and contact details.

As the first step, I have created a blog in blogger. In the Blogger dashboard, please also note the parameter called blog ID which is a kind of unique identifier to the blog. It is needed while making REST calls to Blogger.


Now, let's go to Google Developer's website to check out some Blogger APIs and their authentication.
We can authorize Blogger APIs in two ways.
  1. By an API key.
  2. By OAuth 2.0 token.
Using API key is the easiest way, but is restricted to read-only access. For Create, Edit, Delete operations we need to depend on OAuth 2.0 method. We will begin with API key and then move on to OAuth 2.0 authentication. API key can be generated from the developer's site itself.


Let's have a quick demo using a rest client. I will be using Advanced REST Client(ARC). I'm using the API for fetching details of posts in the blog. In the url, we must add Blog Id and as a query param we need to add API key. On the API call, we received 200 response code and the response contains details about blog posts like post title, post contents etc.


Now we can check on the API used to create blog post. As said earlier we need to obtain auth 2.0 token for the API. Here is the API for post creation.


For our experiment, we can depend on Google's OAuth 2.0 playground. It's a place where we can generate an OAuth token for development purposes. It has a list of APIs from Google, but we will stick with Blogger API. Authorize the API and exchange authorization code for OAuth token.




Let's create a post via rest client using our OAuth 2.0 token. As the header parameters add OAuth token with keyword 'Bearer '. In the request body, add Blog Id, Post Title, and Post Contents. Do the POST operation and you could see the 200 OK response along with the details we sent.


Refresh the blog, so we could see the new post we just made.


Moving on to real codes, the major modules in the project are an HTML template, Python code for reading Excel and posting to Blogger.
  • In the HTML template everything written inside double curly braces such as bank name, branch name, IFSC code will be replaced by values from excel sheet.
  • Using xlrd library we will open the file, and then iterate from first to final row of the sheet and collect details.
  • The core part is creating and publishing a blog post. The POST URL, Body, Headers are constructed from details - OAuth token received as an argument, Blog Id, modified HTML template by excel data.

The code can be found on this Github Repository - PythonicWad
After executing the Python code, You can see the list of posts being published in the Blog.


Blog for Reference - IFSC Codes of BHARAT COOPERATIVE BANK MUMBAI
If you have any suggestions/corrections please let me know from Comment Section. Thanks

Comments

  1. The article was up to the point and described the information very effectively. Thanks to blog author for wonderful and informative post.
    Security Service

    ReplyDelete
  2. It's very informative thanks for sharing such a beautiful article keep sharing

    ReplyDelete
  3. Post is really supportive to all of us. Eager that these kind of information you post in future also. Otherwise if anyone want to Learn Python, Data Science, Machine Learning Course Visit here- http://pythontrainingdelhi.com/

    python training center in delhi
    python training Course in delhi
    python training Institute in delhi

    ReplyDelete
  4. This is the first time I have seen the innovative use of automation for blog posts. I assisted a company to build mobile application that will be used to automate data collection. Automation has indeed gained prominence among many organizations.

    ReplyDelete
  5. Hi, Thanks for sharing. Very informative and very useful for me.
    PYTHON TRAINING IN HYDERABAD

    ReplyDelete
  6. Thanks for sharing and it was useful and knowlegable blog.Keep posting. otherwise anyone wants to learn Advanced Java Course so contact here- +91-9311002620 or visit website- https://www.htsindia.com/Courses/java/advanced-java-training-institute-in-delhi

    ReplyDelete
  7. Skills Hai to Future Hai. Learn Python Programming Languages & Grow Your Skills and Future.

    python training institute in delhi
    python training course in delhi

    ReplyDelete
  8. Nice content and interesting blog. join 360digitmg for the Artificial Intelligence Training Course.
    https://360digitmg.com/artificial-intelligence-ai-course-training-in-hyderabad

    ReplyDelete
  9. Learn Python Programming Course Basic to Advanced Level - Life is Short - you Need Python Course. Further More Details Here-+91-9310332343.

    Python training course in Delhi
    Python training institute in Delhi

    ReplyDelete
  10. Amazing information,thank you for your ideas.after along time i have studied an interesting information's
    by cognex is the AWS Training in Chennai

    ReplyDelete
  11. Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective.

    Python Training Institute in Delhi

    ReplyDelete
  12. I really appreciate your hard work you put into your blog and detailed information you provide. Further More Information About Python training institute in Delhi Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/python/python-training-institute-in-south-delhi

    ReplyDelete
  13. Thanks for sharing this post if anyone looking for Core and Advanced Java training institute in delhi so contact here +91-9311002620 visit https://www.htsindia.com/java-training-courses

    ReplyDelete
  14. Your content is really good thanks for sharing this post thank you if anyone looking for Core and Advanced Java training institute in delhi so contact here +91-9311002620 visit https://www.htsindia.com/java-training-courses

    ReplyDelete
  15. Big thank you for sharing this post its very knowledgeable and very helpful i hope that you will continue to post these kinds of contents in future apart from that if anyone looking for e accounting institute in delhi so Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/Tally/e-accounting-training-course

    ReplyDelete
  16. Thanks for sharing this valuable post its very informative and very helpful apart from that if anyone looking for e accounting institute in delhi so Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/Tally/e-accounting-training-course

    ReplyDelete
  17. thank you for sharing this post its really awesome apart from that if anyone looking for e accounting institute in delhi so Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/Tally/e-accounting-training-course

    ReplyDelete
  18. Big thanks for sharing this post apart form that if anyone look for Python training institute in Delhi Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/python/python-training-institute-in-delhi

    ReplyDelete
  19. Wow! Thank you! I constantly wanted to write on my site something like that. Can I take a portion of your post to my website? best python string methods service provider.

    ReplyDelete
  20. I admire this article for well-researched content and excellent wording. Thank you for providing such a unique information here. Vietnam Import Data

    ReplyDelete
  21. A big thanks for sharing this post by the way if anyone looking for Best Consulting Firm for Fake Experience Certificate Providers in mumbai, India with Complete Documents So Dreamsoft Consultancy is the Best Place.Further Details Here- 9599119376 or VisitWebsite-https://experiencecertificates.com/experience-certificate-provider-in-mumbai.html

    ReplyDelete
  22. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.

    No-1 Python Training Institute in Delhi with Placement Assistance

    ReplyDelete
  23. Your post is really good thanks for sharing these kind of post but if anyone looking for Best Consulting Firm for Fake Experience Certificate Providers in noida, India with Complete Documents So Dreamsoft Consultancy is the Best Place.Further Details Here- 9599119376 or Visit
    Website-https://experiencecertificates.com/experience-certificate-provider-in-Noida.html

    ReplyDelete
  24. Great Info, Your blog is very informative and interesting, your all post are amazing, keep sharing more interesting topics. Thanks for the blog. It really helps me a lot.

    Innovative Approaches to Improve Your Python Training Course
    Reasons Why You Should Learn Python Training Course

    ReplyDelete
  25. Wow your content is awesome and very helpful and knowledgeable thanks for sharing there kinds of posts apart from that if anyone looking for best institute for Advanced Excel training so contact here +91-9311002620 visithttps://www.htsindia.com/Courses/business-analytics/adv-excel-training-course

    ReplyDelete
  26. I want to leave a little comment to support and wish you the best of luck. We wish you the best of luck in all your blogging endeavors. Otherwise if any One Want to Learn Complete Python Training Course - No Coding Experience Required So Contact Us.

    Complete Python Training Course - No Coding Experience Required

    ReplyDelete
  27. I prefer high-quality content, which I discovered in your article about Python Training Institute in Delhi. The information you've provided is useful and important to us. Continue to post articles like these. Thank you very much.

    ReplyDelete
  28. I Would like to thank you for this article. From this article I got more and more useful information. This is so helpful to me. Keep updating more articles.
    Ubs accounting
    Myob Singapore
    Best Accounting software Singapore

    `

    ReplyDelete
  29. Excellent data with lots of information. I have bookmarked this page for my future reference. Do share more updates.
    Tally Classes in Chennai
    Tally Certification Course
    Tally course in Coimbatore

    ReplyDelete
  30. You've supplied us with an interesting article about Software Development Training Courses Online. This is a fantastic resource for expanding your understanding of the subject. Thank you very much.

    ReplyDelete
  31. I really liked while reading your article, the information you have mentioned in this post is really good. I am waiting for your upcoming post your ,post is really good . Otherwise if anyone want to Learn javaCourse So Contact Us-9311002620 Or check my website- https://www.htsindia.com/Courses/tally/tally-training-course

    ReplyDelete
  32. This blog is very nice , you write the quality content. I read all of your blog. If anyone want to know more about pyhton or want to learn can contact me at 9311002620 or can visit our website https://www.htsindia.com/Courses/python/python-training-institute-in-south-delhi

    ReplyDelete
  33. Your post is really good thanks for sharing these kind of post but if anyone looking for Best Consulting Firm for Fake Experience Certificate Providers in chennai, India with Complete Documents So Dreamsoft Consultancy is the Best Place.Further Details Here- 9599119376 or VisitWebsite- https://experiencecertificates.com/experience-certificate-pr

    ReplyDelete
  34. Your post is really good thanks for sharing these kind of post but if anyone looking for Best Consulting Firm for Fake Experience Certificate Providers in gurgaon India with Complete Documents So Dreamsoft Consultancy is the Best Place.Further Details Here- 9599119376 or VisitWebsite-https://experiencecertificates.com/experience-certificate-provider-in-Gurgaon.html

    ReplyDelete
  35. Thanks for writing blog, your blogs are very nice and knowledgable. If anyone want to know more about pyhton or want to learn can contact me at 9311002620 or can visit our website
    Sas Training Institute In Delhi
    Advance Excel Training Institute In Delhi
    Python Training Institute In Delhi

    ReplyDelete
  36. Thank you for sharing this great post its very helpful but if anyone looking for Experience Certificate Providers in Noida, India with Complete Documents So Dreamsoft Consultancy is the Best Place.Further Details Here- 9599119376 or Visit Website-Website-https://experiencecertificates.com/experience-certificate-provider-in-Noida.html

    ReplyDelete
  37. Very informative post. Really appreciable work.
    Python programming knowledge is also required skills for IT network engineers. Python for network engineers provide basic level of automation and coding skills in Python.
    Thanks
    CCNA Online Course

    ReplyDelete
  38. Very nice post thank you for sharing this post its very knowledgeable and very helpful i hope that you will continue to post these kinds of contents in future apart from that if anyone looking for Advance Excel institute in delhi so Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/business-analytics/adv-excel-training-course

    ReplyDelete
  39. Happy to read this type of valuable content ,like the way of presenting your knowlege.If anyone want to get experience in Delhi can contact me at - 9599119376
    Experience Certificate In Delhi
    Experience Certificate In Bangalore
    Experience Certificate In Hyderabad
    Experience Certificate In Noida

    ReplyDelete
  40. Thank you for sharing this kind of informative post i your content helped me alot apart that if anyone looking for best institute for java training so contact here +91- 9311002620 or visit https://www.htsindia.com/java-training-courses

    ReplyDelete
  41. Have to work? need of money but have no experience certificate. Get in touch with us we provide experience certificate in Mumbai 100% genuine certificate in Mumbai. It will help it your courier. So don’t be late. Get your experience letter now. For experience letter in Mumbai contact at 9599119376 or can visit our website at https://experiencecertificates.com/experience-certificate-provider-in-mumbai.html

    ReplyDelete

Post a Comment

Popular posts from this blog

How to install Ubuntu Server and set up static IP (WiFi) on Raspberry Pi 3

The beginning of Data Quest

Setting up Python Flask server on internet via Port forwarding

Creation of Orphan Process in Linux using Python