Php 当网站上的任何内容发生变化时,通知谷歌网站地图的变化

Php 当网站上的任何内容发生变化时,通知谷歌网站地图的变化,php,seo,xml-sitemap,Php,Seo,Xml Sitemap,我使用了Wordpress的插件,每当你发表新文章时,它会通知一些搜索引擎。然而,我正在考虑开发一个用户提交资料的网站,我如何使用PHP在网站发生变化时用XML站点地图(或类似方法)通知谷歌,以便谷歌可以快速搜索/索引用户提交的资料。对于ping Google,ping url是: 向以下URL发出请求:www.google.com/webmasters/tools/ping?sitemap=sitemap\u URL 使用wget、curl或您选择的其他机制发出HTTP请求。 成功的请求将返

我使用了Wordpress的插件,每当你发表新文章时,它会通知一些搜索引擎。然而,我正在考虑开发一个用户提交资料的网站,我如何使用PHP在网站发生变化时用XML站点地图(或类似方法)通知谷歌,以便谷歌可以快速搜索/索引用户提交的资料。

对于ping Google,ping url是:


向以下URL发出请求:
www.google.com/webmasters/tools/ping?sitemap=sitemap\u URL
使用wget、curl或您选择的其他机制发出HTTP请求。 成功的请求将返回HTTP 200响应代码,如果收到不同的响应,则应重新提交请求。

对于
PHP

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

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