Скрипт для копирования запросов из вкладки «Эффективность → Управление группами» в Яндекс Вебмастер

Koukou Roukou
На сайте с 13.10.2024
Offline
25
1343

Здравствуйте, товарищи.

Тут на днях выяснилось, что не все знают про вкладку «Эффективность → Управление группами» в Яндекс Вебмастер. А ведь там по сути все запросы, по которым ваш сайт имеет видимость на серпе. Т.е. это запросный индекс вашего сайта. Там можно отфильтровать данные по URL, по тексту запроса или посмотреть вообще всё запросы, по которым есть видимость.

В общем, понадобилось все запросы оттуда собрать, а Key Сollector почему-то собирать данные Вебмастера отказался.

Напару с нейросетью тут скрипт накидал, вдруг кому-то пригодится.

Настраиваете фильтр, вставляете в консоль в браузере, поправляете количество страниц в 3-ей строчке, жмёте Enter и все запросы оттуда собираете.

При необходимости можно допилить скрипт и собирать показы, клики, CTR или позицию по запросу (мне это было не нужно).

(async () => {
    const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
    const maxPages = 5; // Максимальное количество страниц для обхода (можно изменить)
    let currentPage = 1;

    const results = [];
    const nextPageButtonSelector = '.pager__page.pager__page_rel_next';

    while (currentPage <= maxPages) {
        console.log(`Сбор данных со страницы ${currentPage}`);
        const rows = document.querySelectorAll('table tr');

        rows.forEach(row => {
            const cells = row.querySelectorAll('td');
            if (cells.length > 0) {
                const query = cells[0].innerText.trim();

                results.push(query);
            }
        });

        const nextPageButton = document.querySelector(nextPageButtonSelector);
        if (nextPageButton) {
            nextPageButton.click();
            await delay(3000);
            currentPage++;
        } else {
            break;
        }
    }

    let resultContent = results.join('\n');

    const container = document.createElement('div');
    container.style.position = 'fixed';
    container.style.top = '10px';
    container.style.left = '10px';
    container.style.width = 'auto';
    container.style.zIndex = '1000';
    container.style.backgroundColor = 'white';
    container.style.border = '1px solid #ccc';
    container.style.padding = '10px';
    container.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';

    const textArea = document.createElement('textarea');
    textArea.value = resultContent;
    textArea.style.width = '1024px';
    textArea.style.height = '300px';
    textArea.style.resize = 'both';
    container.appendChild(textArea);

    const buttonContainer = document.createElement('div');
    buttonContainer.style.display = 'flex';
    buttonContainer.style.justifyContent = 'space-between';
    buttonContainer.style.marginTop = '5px';
    container.appendChild(buttonContainer);

    const copyButton = document.createElement('button');
    copyButton.innerText = 'Скопировать';
    copyButton.style.flex = '1';
    copyButton.style.marginRight = '10px';
    copyButton.addEventListener('click', () => {
        textArea.select();
        document.execCommand('copy');
        alert('Данные скопированы в буфер обмена!');
    });
    buttonContainer.appendChild(copyButton);

    const closeButton = document.createElement('button');
    closeButton.innerText = 'Закрыть';
    closeButton.style.flex = '1';
    closeButton.addEventListener('click', () => {
        document.body.removeChild(container);
    });
    buttonContainer.appendChild(closeButton);

    document.body.appendChild(container);
})();

Комментарий маэстро по теме запросного индекса


Кина не будет, электричество кончилось. Результаты экспериментов публиковать не буду. Результаты AB-тестов рекламы тоже. Аккаунт можно аннигилировать.

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий