The example in this paper describes how Python uses the Xmlrpclib module to ping Baidu Google. Share to everyone for your reference. The specific analysis is as follows:
Recently in doing SEO, in order to let the outside chain can be quickly included, think of the use of ping function, Google and Baidu are related to the Ping introduced, interested friends can go to see the relevant knowledge. The implementation of the PING function in addition to some open-source blog programs, such as WP, it can be set in the background ping address, as long as the set up, you post, will automatically notify the search engine, my blog has been updated, and today I use the method is not through the WP and other ping features of the blog, I use Python to ping the search engine locally, so as to achieve a quick inclusion of the effect.
Import reurlinfo = "Http://www.cnpythoner.com/post/181.htmlurl2url3" def Ping (webname,hosturl,linkurl): Import xmlrpclib rpc_server = xmlrpclib. Serverproxy (' http://blogsearch.google.com/ping/RPC2 ') result = Rpc_server.weblogUpdates.extendedPing (webname , Hosturl,linkurl) print result if Result.get (' Flerror ', False) = = True: print ' ping error ' else: print ' ping success ' def get_url (URL): ' get the standard URL ' ' host_re = Re.compile (R ' ^https?:/ /(.*?) ($|/) ', re. IGNORECASE ) return Host_re.search (URL). Group (0) info = urlinfo.split (' \ n ') for M in info: webname = M.split ('. ') [1] Hosturl = Get_url (m) Ping (webname,hosturl,m)
If the returned result is {' message ': ' Thanks for the ping ', ' Flerror ': False}, stating that it has been successfully ping, congratulations, hehe.
This is mostly the use of Python xmlrpclib.
Hopefully this article will help you with Python programming.