开发者

Notify Google of sitemap change when any content on website changes

开发者 https://www.devze.com 2023-02-04 09:23 出处:网络
I\'ve used 开发者_运维百科Wordpress\'s plugin that notifies a few search engines every time you make a new post. However i\'m thinking of developing a website that users submit stuff to, how can i use

I've used 开发者_运维百科Wordpress's plugin that notifies a few search engines every time you make a new post. However i'm thinking of developing a website that users submit stuff to, how can i use PHP to notify Google with an XML sitemap (or similar method) of the site changes as and when they happen, so users submissions are searchable/indexed quickly by Google.


To ping Google, the ping url is:

http://www.google.com/webmasters/sitemaps/ping?sitemap=http://www.yoursite.com/sitemap-file.xml


For PHP:

file_get_contents("https://www.google.com/webmasters/sitemaps/ping?sitemap=https://domain.tld/sitemap.xml")

For Python:

import requests
requests.get("https://www.google.com/webmasters/sitemaps/ping?sitemap=https://domain.tld/sitemap.xml")


shell_exec('ping -c1 www.google.com/webmasters/sitemaps/ping?sitemap=http://www.website.com/sitemap.php');


Issue your request to the following URL: www.google.com/webmasters/tools/ping?sitemap=sitemap_url Issue the HTTP request using wget, curl, or another mechanism of your choosing. A successful request will return an HTTP 200 response code, if you receive a different response, you should resubmit your request.

0

精彩评论

暂无评论...
验证码 换一张
取 消