Facebook doesn't crawl my site's urls automatically

我只是一个虾纸丫 提交于 2019-12-25 06:25:54

问题


I have blog post urls like these:

http://www.topluisilanlari.com/blog/goster/48/abc

Firstly please change abc part(it doesn not makes diffrence for page). When i try to share this url at facebook it does not show image of page(there is og:image property at code) but when i enter same url at facebook debugger and click "Fetch new scrape information" button then my page image showing properly and at sharing function too.

How can i fix that ?

Thanks.


回答1:


https://developers.facebook.com/docs/sharing/best-practices#precaching:

When content is shared for the first time, the Facebook crawler will scrape and cache the metadata from the URL shared. The crawler has to see an image at least once before it can be rendered. This means that the first person who shares a piece of content won't see a rendered image

There are two ways to avoid this and have images render on the first Like or Share action:

1. Pre-cache the image with the URL Debugger
Run the URL through the URL debugger to pre-fetch metadata for the page. You should also do this if you update the image for a piece of content.

2. Use og:image:width and og:image:height Open Graph tags
Using these tags will specify the image to the crawler so that it can render it immediately without having to asynchronously.

So do the second one – specify the dimensions of your preview image through those og meta tags.




回答2:


Facebook does not crawl URLs regularly: it is not a search engine. It scrapes a page when it is first shared and saves this information until you re-scrape or re-fetch the page (as you have tried).

More information on open graph, with examples, can be found on http://ogp.me although this open graph generator may help you in future.

When I looked at the scrape information today it contained errors, and meta tags did not end with /> (only with >). It looks like re-scraping the page, which I have just done, has fixed this. The only warning now can be fixed by adding:

<meta property="og:url" content="http://www.topluisilanlari.com/blog/goster/48/abc"/> 

Your code has several problems, it has validation errors although these aren't causing the sharing problem.




回答3:


If someone is coming across this looking for details on how to make Facebook crawl a URL programmatically then the answer is on this page: https://developers.facebook.com/docs/sharing/opengraph/using-objects#update

Send a POST request with the URL you want to get scraped/crawled and add on the query parameter ?scrape=true or &scrape=true to that URL(accordingly). Also add the Access Token in the request.

Below is an example of the post request in WordPress but you can manipulate it for Guzzle, Curl etc. The endpoint would be https://graph.facebook.com and the body would be an array containing the URL with the ?scrape=true query param and the access token.

$scrape['id'] = $yoururl . '?scrape=true';
$scrape['access_token'] = $access_token;

$response = wp_remote_post(
                'https://graph.facebook.com',
                array(
                    'body' => $scrape,
                    'headers' => array(
                        'Content-Type' => 'application/x-www-form-urlencoded',
                    ),
                    'timeout' => 60,

                )
            );
print_r($response, true); //would echo out the results of the srape


来源:https://stackoverflow.com/questions/30165840/facebook-doesnt-crawl-my-sites-urls-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!