Python uses the Xmlrpclib module to achieve a ping work on Baidu Google

Source: Internet
Author: User

This example describes Python using the Xmlrpclib module to achieve the ping function of Baidu Google. Share to everyone for your reference. The specific analysis is as follows:

Recently in doing SEO, in order to allow the hair of the chain can be quickly included, thought of the use of ping function, Google and Baidu have related ping introduction, interested friends can go to see the relevant knowledge. In addition to being able to use a few open source blog programs, the ping feature for example, 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 WP and so with ping function blog, I use Python to ping the search engine locally, so as to achieve the effect of rapid collection.

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24-25 import Re urlinfo = ' http://www.cnpythoner.com/post/181.html url2 url3 ' def ping (webname,hosturl,linkurl): Import XM Lrpclib 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 g Et_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 ') to M in info:webname = M.split ('. ') [1] hosturl = Get_url (M) Ping (webname,hosturl,m)

If the result returned is {' message ': ' The ' for the ' ping. ', ' Flerror ': False}, the description has ping success, congratulations, hehe.

This is mainly the use of Python xmlrpclib.

I hope this article will help you with your 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.