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 blogsProgramFor example, WP can set the ping address in the background. After setting the ping address, you can send a post to automatically notify the search engine that my blog has been updated, today, I am using a method that does not use WP or other blogs with the Ping function. I use python to ping the search engine locally to achieve quick indexing. AttachedCode:
Import re
Urlinfo ='''Http: // www.cnpythoner.com/post/181.html
Url2url3
'''
DefPing (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 '
DefGet_url (URL ):
'''Get standard url '''
Host_re = Re. Compile (R' ^ HTTPS? ://(.*?) ($ | /)',
Re. ignorecase
)
ReturnHost_re.search (URL). Group (0)
Info = urlinfo. Split ('\ N')
ForMInInfo:
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.
I hope to help you. It is mainly used in Python xmlrpclib.