This article mainly introduces how to use the xmlrpclib module in python to ping Baidu and google. The example analyzes the related skills of the xmlrpclib module, for more information about how to use the xmlrpclib module to ping Baidu and google, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
Recently, when I was doing SEO, in order to enable quick indexing of external links, I thought of using the ping function. Both google and Baidu have related ping introduction, if you are interested, you can check related knowledge. In addition to some open-source blog programs, such as WP, you can set the ping address in the background to send a post after the ping function is configured, I will automatically notify the search engine that my blog has been updated. Now I am using a method that does not pass the WP or other blogs with the ping function, ping the search engine locally using python to achieve quick indexing.
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 standard ur L ''' 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}, the ping is successful. Congratulations.
Python xmlrpclib is used here.
I hope this article will help you with Python programming.