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.