Python uses the Xmlrpclib module to achieve ping function for Baidu Google

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

  • Related Article

    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.