S
S
Stanislav2018-09-17 13:17:34
API
Stanislav, 2018-09-17 13:17:34

How to send turbo pages to webmaster yandex?

Maybe I misunderstood something.
On the tab with turbo pages it says

Loading via API
For large sites. Batch download. Up to 10,000 items in each task, up to 10 tasks at the same time.

As I understood it: we get a link to api, generate XML with item fields and push them all together using the POST method using the provided link. Am I right or not?
I started the process of getting a link, everything is ok, I did everything.
Pulled 10 documents from the database and formed XML from them
function getItemsXML(request) {
    return xml = `<?xml version="1.0" encoding="UTF-8"?><rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel>`,
        Promise.all(request.map(async (document) => {
            xml += `<item turbo="true"><link>${document.url}</link><turbo:content><![CDATA[<header><h1>Фото ${document.tags.slice(0, 3).join(', ')}</h1></header><pubDate>${document.indexAt.toUTCString()}</pubDate><figure><img src="${document.image}"><figcaption>Бесплатное фото ${document.tags.slice(-3).join(', ')}</figcaption></figure>]]></turbo:content></item>`
        })), xml + `</channel></rss>`
}

Same structure in usual rss for turbo pages
Trying to add these elements via api
function pushYandexTurboItems(request) {
    return options.uri = request.address, options.headers['Content-type'] = 'application/rss+xml', options.FormData = request.rss,
        http.post(options).then()
}

Throws out an error
body:
      { error_message: 'Expected valid xml, found: "..."',
        error_code: 'ENTITY_VALIDATION_ERROR' }

Decryption
ENTITY_VALIDATION_ERROR — тело запроса не прошло валидацию.

What's wrong?
Tried to pass an array of elements
return Promise.all(request.map(async (document) => {
        return `<item turbo="true"><link>${document.url}</link><turbo:content><![CDATA[<header><h1>Фото ${document.tags.slice(0, 3).join(', ')}</h1></header><pubDate>${document.indexAt.toUTCString()}</pubDate><figure><img src="${document.image}"><figcaption>Бесплатное фото ${document.tags.slice(-3).join(', ')}</figcaption></figure>]]></turbo:content></item>`
    }))

Same error.
I think maybe I did not understand the purpose of this api at all?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
developerbitrix, 2018-11-21
@developerbitrix

I also ran into the same problem, it was in the encoding. Rss must be in utf-8.

M
maxxi165, 2019-01-10
@maxxi165

The feed must start with <rss
an example from the docks

F
fomiash, 2020-05-31
@fomiash

Class for sending turbopages from YandexAPI
It is worth adding that Yandex turbo pages are very capricious, if the limits of text, blocking, number of pictures, etc. are exceeded, there may be problems with loading the feed, incomplete loading, and it does not often return a specific error. I have experience of connecting tens of thousands of pages of the site to turbo pages, this resulted in writing functionality that forms normal, valid text from articles (long sentences are broken, there was a lot of trouble with this), embedded images are checked for response before sending (yes, and this important too). It is also worth paying attention to the obsolescence of the API reference, which needs to be received approximately once an hour, and the inability to work normally in test mode. There are a lot of nuances, but by overcoming them you can see the satisfied smile of the SEO specialist, which is worth a lot)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question