Kim Hans  Jin

Kim Hans Jin


How to Connect WordPress Site using Python

There are many readily available libraries that one can use with Python to connect to WordPress’ XML-RPC interface in order to make queries and add/delete/modify content.

A personal favourite is the WordPress XML-RPC library that can be easily integrated into python with pip. Simply install the library and you’re ready to start writing scripts to manipulate content on wordpress!

Load the libraries in your Python code

This is obvious. I’ll provide a snippet that imports all the necessary modules to do pretty much anything in WordPress.

from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.taxonomies import *
from wordpress_xmlrpc.methods.posts import *
from wordpress_xmlrpc.methods.users import *
from wordpress_xmlrpc.methods import *

There’s not much else to say here, though it would be ideal to only load what you need to minimize the footprint as much as possible.

Authenticating with WordPress

This too is obvious. With the XML-RPC library, you need to define the credentials needed in order to make the connection. If you are planning on writing a useful Python script that will ultimately end up on a public forum such as github, it would be ideal to use the Python module called ConfigParser. This will allow to to store authentication details in a safe place, such as your home folder in a hidden file perhaps.

Either way this is how you would define those connection details :

wp_url = ''
wp_username = 'username'
wp_password = 'password'

To actually authenticate a session in order to perform tasks, you will need to use the above variables in a connection string :

# Get blog URL
wp_site = Client(wp_url, wp_username, wp_password)
siteurl =['home_url']))[0].value

The Client directive is what makes the connection. The next line, siteurl is simply pulling the home url variable from WordPress’ settings and storing it in a variable. That is the simple function that we conduct that obviously requires a WordPress authenticated session in order to complete.

Searching all post titles in WordPress with Python

There are countless guides out there that show you how to integrate Python and WordPress. What we found was lacking was how to make more complicated queries and searches within WordPress. One of our requirements was the ability to make posts to WordPress but first check if any posts of the same title exist. This is obviously not perfect for example what if two different posts have the same title? Either way, this is a good place to start with respect to building a definition in Python to conduct these types of queries.

#Searches wordpress posts based on title
def find_id(title):
    offset = 0
    increment = 20
    while True:
        filter = { 'offset' : offset }
        p =
        if len(p) == 0:
            break # no more posts returned
        for post in p:
            if post.title == title:
        offset = offset + increment

So the above definition basically queries for all posts with an iteration of 20 posts at a time (think pagination). Each post’s title is pulled from the list and compared to the title that was originally passed to the definition, “title”.

Pretty simple, huh? It took us a little bit to perfect this so it actually worked with some semblance of reliability.

Search WordPress tags with Python

What if you wanted to do the same thing with WordPress tags instead? This is where we found very little documentation specifically on the subject. We took the above definition and modified it to accommodate searching tags.

def find_id(tag):
     p ='post_tag'))
     if len(p) == 0:
     for thetags in p:
         print 'looking for tag : ' , tag , ' in thetags : ' , str(thetags)
         if str(thetags) in tag:

You’ll see that we took the first definition and modified it. One of the first things you’ll notice is that we’re no longer looping through all posts in increments. You’ll also notice the function is a bit different. I would hope that its pretty self explanatory. The only other thing to note here is that the thetags variable had to be force converted to a string variable type. These queries did not work unless that happened simply because we are comparing a string (tag) to a hashed list (thetag before converting to string). If there’s a better way, I’m open to suggestions!

Search all WordPress post content with Python

Why not take it one step further? Why not write a definition that allows you to search all post content for a particular word or string? I cant think of practical uses for this because it would depend on the root use case for your python script would be. One of the best things that python can do is scrape and pull information from all sorts of sources. Integrating this information into WordPress via python is sometimes much much easier than writing a custom WordPress plugin simply because of the fact that if you are dealing with data sets, data sources and API’s from other web sources, Python is much better suited (in most cases) to perform this data integration and connection than WordPress or PHP for that matter. This was what we found when we wanted to integrate TREB into WordPress. We were pulling complicated and obfuscated CSV data and had to clean it up, grab what data was necessary and then import it into WordPress.

#Searches wordpress post content for anything
def find_id(content):
        offset = 0
        increment = 20
        while True:
                filter = { 'offset' : offset }
                p =
                if len(p) == 0:
                        break # no more posts returned
                for post in p:
                        if post.content.find(content) != -1:
                                post.post_status = 'unpublish'
                                # We remove the post if its found, but you could do anything
                      , post))
                offset = offset + increment

You’ll see in the above example that we search all post content (this time back to the 20 posts per increment). If a match is found, we remove the post or unpublish it at least. You can do anything obviously, but this is what we wanted to happen.

I hope this helps!

#python #wordpress

What is GEEK

Buddha Community

How to Connect WordPress Site using Python

Why Use WordPress? What Can You Do With WordPress?

Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.
What Is The Use Of WordPress?

WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is – everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Let’s start knowing them:

1. Multiple Websites Under A Single Installation
WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.
It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.

2. WordPress Social Network
WordPress can be used for high-end projects such as Social Media Network. If you don’t have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.
To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.
If BuddyPress doesn’t meet all your needs, don’t give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.

3. Create A Forum For Your Brand’s Community
Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page – the good old WordPress is still the best.
It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesn’t hamper the experience of the website.
Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.

4. Shortcodes
Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.
There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.

5. Build Online Stores
If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.
WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you don’t have to pay for the license.
Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.

6. Security Features
WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.
By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.

Read More

#use of wordpress #use wordpress for business website #use wordpress for website #what is use of wordpress #why use wordpress #why use wordpress to build a website

Ray  Patel

Ray Patel


top 30 Python Tips and Tricks for Beginners

Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.

1) swap two numbers.

2) Reversing a string in Python.

3) Create a single string from all the elements in list.

4) Chaining Of Comparison Operators.

5) Print The File Path Of Imported Modules.

6) Return Multiple Values From Functions.

7) Find The Most Frequent Value In A List.

8) Check The Memory Usage Of An Object.

#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners

Ray  Patel

Ray Patel


Lambda, Map, Filter functions in python

Welcome to my Blog, In this article, we will learn python lambda function, Map function, and filter function.

Lambda function in python: Lambda is a one line anonymous function and lambda takes any number of arguments but can only have one expression and python lambda syntax is

Syntax: x = lambda arguments : expression

Now i will show you some python lambda function examples:

#python #anonymous function python #filter function in python #lambda #lambda python 3 #map python #python filter #python filter lambda #python lambda #python lambda examples #python map

Shardul Bhatt

Shardul Bhatt


Why use Python for Software Development

No programming language is pretty much as diverse as Python. It enables building cutting edge applications effortlessly. Developers are as yet investigating the full capability of end-to-end Python development services in various areas. 

By areas, we mean FinTech, HealthTech, InsureTech, Cybersecurity, and that's just the beginning. These are New Economy areas, and Python has the ability to serve every one of them. The vast majority of them require massive computational abilities. Python's code is dynamic and powerful - equipped for taking care of the heavy traffic and substantial algorithmic capacities. 

Programming advancement is multidimensional today. Endeavor programming requires an intelligent application with AI and ML capacities. Shopper based applications require information examination to convey a superior client experience. Netflix, Trello, and Amazon are genuine instances of such applications. Python assists with building them effortlessly. 

5 Reasons to Utilize Python for Programming Web Apps 

Python can do such numerous things that developers can't discover enough reasons to admire it. Python application development isn't restricted to web and enterprise applications. It is exceptionally adaptable and superb for a wide range of uses.

Robust frameworks 

Python is known for its tools and frameworks. There's a structure for everything. Django is helpful for building web applications, venture applications, logical applications, and mathematical processing. Flask is another web improvement framework with no conditions. 

Web2Py, CherryPy, and Falcon offer incredible capabilities to customize Python development services. A large portion of them are open-source frameworks that allow quick turn of events. 

Simple to read and compose 

Python has an improved sentence structure - one that is like the English language. New engineers for Python can undoubtedly understand where they stand in the development process. The simplicity of composing allows quick application building. 

The motivation behind building Python, as said by its maker Guido Van Rossum, was to empower even beginner engineers to comprehend the programming language. The simple coding likewise permits developers to roll out speedy improvements without getting confused by pointless subtleties. 

Utilized by the best 

Alright - Python isn't simply one more programming language. It should have something, which is the reason the business giants use it. Furthermore, that too for different purposes. Developers at Google use Python to assemble framework organization systems, parallel information pusher, code audit, testing and QA, and substantially more. Netflix utilizes Python web development services for its recommendation algorithm and media player. 

Massive community support 

Python has a steadily developing community that offers enormous help. From amateurs to specialists, there's everybody. There are a lot of instructional exercises, documentation, and guides accessible for Python web development solutions. 

Today, numerous universities start with Python, adding to the quantity of individuals in the community. Frequently, Python designers team up on various tasks and help each other with algorithmic, utilitarian, and application critical thinking. 

Progressive applications 

Python is the greatest supporter of data science, Machine Learning, and Artificial Intelligence at any enterprise software development company. Its utilization cases in cutting edge applications are the most compelling motivation for its prosperity. Python is the second most well known tool after R for data analytics.

The simplicity of getting sorted out, overseeing, and visualizing information through unique libraries makes it ideal for data based applications. TensorFlow for neural networks and OpenCV for computer vision are two of Python's most well known use cases for Machine learning applications.


Thinking about the advances in programming and innovation, Python is a YES for an assorted scope of utilizations. Game development, web application development services, GUI advancement, ML and AI improvement, Enterprise and customer applications - every one of them uses Python to its full potential. 

The disadvantages of Python web improvement arrangements are regularly disregarded by developers and organizations because of the advantages it gives. They focus on quality over speed and performance over blunders. That is the reason it's a good idea to utilize Python for building the applications of the future.

#python development services #python development company #python app development #python development #python in web development #python software development

How To Compare Tesla and Ford Company By Using Magic Methods in Python

Magic Methods are the special methods which gives us the ability to access built in syntactical features such as ‘<’, ‘>’, ‘==’, ‘+’ etc…

You must have worked with such methods without knowing them to be as magic methods. Magic methods can be identified with their names which start with __ and ends with __ like init, call, str etc. These methods are also called Dunder Methods, because of their name starting and ending with Double Underscore (Dunder).

Now there are a number of such special methods, which you might have come across too, in Python. We will just be taking an example of a few of them to understand how they work and how we can use them.

1. init

class AnyClass:
    def __init__():
        print("Init called on its own")
obj = AnyClass()

The first example is _init, _and as the name suggests, it is used for initializing objects. Init method is called on its own, ie. whenever an object is created for the class, the init method is called on its own.

The output of the above code will be given below. Note how we did not call the init method and it got invoked as we created an object for class AnyClass.

Init called on its own

2. add

Let’s move to some other example, add gives us the ability to access the built in syntax feature of the character +. Let’s see how,

class AnyClass:
    def __init__(self, var):
        self.some_var = var
    def __add__(self, other_obj):
        print("Calling the add method")
        return self.some_var + other_obj.some_var
obj1 = AnyClass(5)
obj2 = AnyClass(6)
obj1 + obj2

#python3 #python #python-programming #python-web-development #python-tutorials #python-top-story #python-tips #learn-python