Python uses the xmlrpclib module to ping Baidu and google

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.