Помогите составить xpath.



  • Нужно в ютубе в комментах под видео найти свой коммент и накрутить активность. Нахожу точный текст (имя акка) и нужно нажать на кнопку ОТВЕТИТЬ (ответить на коммент). Проблема в том, что между текстом и кнопкой, дофигище кода.
    В благодарность могу поделиться этим софтом, если нужен.

    <div id="main" class="style-scope ytd-comment-renderer">
        <div id="header" class="style-scope ytd-comment-renderer">
          <div id="header-badge" class="style-scope ytd-comment-renderer" hidden="">
            <div id="linked-comment-badge" class="style-scope ytd-comment-renderer" hidden=""></div>
            <div id="pinned-comment-badge" class="style-scope ytd-comment-renderer" hidden=""></div>
          </div>
    
          <div id="header-author" class="style-scope ytd-comment-renderer">
            <h3 class="style-scope ytd-comment-renderer">
              <a id="author-text" class="yt-simple-endpoint style-scope ytd-comment-renderer" href="/channel/UC-ksw_fiIRxqFlToLkYezLQ">
                <span class="style-scope ytd-comment-renderer">
                  _Magical-Friends_
                </span>
              </a>
            </h3>
            <span id="author-comment-badge" class="style-scope ytd-comment-renderer" hidden=""></span>
            <span id="sponsor-comment-badge" class="style-scope ytd-comment-renderer" hidden=""></span>
            
            <yt-formatted-string class="published-time-text above-comment style-scope ytd-comment-renderer" enable-empty-style-class="" has-link-only_=""><a class="yt-simple-endpoint style-scope yt-formatted-string" spellcheck="false" href="/watch?v=6V2bt-ac8ow&amp;lc=UgxlxpoYIU47j-lLk6F4AaABAg" dir="auto">2 года назад</a></yt-formatted-string>
            <span id="author-reputation" class="style-scope ytd-comment-renderer"></span>
            <span id="sponsors-only-badge" class="style-scope ytd-comment-renderer" hidden=""></span>
    
            <span id="moderation-reason-divider" class="style-scope ytd-comment-renderer" hidden="">
              •
            </span>
            <span id="moderation-reason-text" class="style-scope ytd-comment-renderer" hidden="">
              
            </span>
          </div>
        </div>
    
        
        <ytd-expander id="expander" max-number-of-lines="4" class="style-scope ytd-comment-renderer" collapsed="" should-use-number-of-lines="" style="--ytd-expander-max-lines:4;"><!--css-build:shady--><div id="content" class="style-scope ytd-expander">
      
      <yt-formatted-string id="voted-option" slot="content" class="style-scope ytd-comment-renderer" disable-upgrade="" hidden="">
          </yt-formatted-string><yt-formatted-string id="content-text" slot="content" split-lines="" class="style-scope ytd-comment-renderer" enable-empty-style-class="">Спасибо большое,дальнейшего развития тебе)</yt-formatted-string>
    </div>
    
    <tp-yt-paper-button id="less" aria-expanded="true" noink="" class="style-scope ytd-expander" hidden="" role="button" tabindex="0" animated="" elevation="0" aria-disabled="false"><!--css-build:shady-->
      <span class="less-button style-scope ytd-comment-renderer" slot="less-button">Свернуть</span>
    </tp-yt-paper-button>
    <tp-yt-paper-button id="more" aria-expanded="false" noink="" class="style-scope ytd-expander" hidden="" role="button" tabindex="0" animated="" elevation="0" aria-disabled="false"><!--css-build:shady-->
      <span class="more-button style-scope ytd-comment-renderer" slot="more-button">Читать дальше</span>
    </tp-yt-paper-button>
    </ytd-expander>
        
        <yt-formatted-string class="published-time-text below-comment style-scope ytd-comment-renderer" enable-empty-style-class="" hidden="true" has-link-only_=""><a class="yt-simple-endpoint style-scope yt-formatted-string" spellcheck="false" href="/watch?v=6V2bt-ac8ow&amp;lc=UgxlxpoYIU47j-lLk6F4AaABAg" dir="auto">2 года назад</a></yt-formatted-string>
        <ytd-comment-action-buttons-renderer id="action-buttons" class="style-scope ytd-comment-renderer" action-buttons-style="desktop-toolbar"><!--css-build:shady--><div id="toolbar" class="style-scope ytd-comment-action-buttons-renderer">
      <div id="reply-button" class="style-scope ytd-comment-action-buttons-renderer">
      </div>
      <span id="vote-count-left" class="style-scope ytd-comment-action-buttons-renderer" hidden="">
        0
      </span>
      <ytd-toggle-button-renderer id="like-button" class="style-scope ytd-comment-action-buttons-renderer style-text size-default" use-keyboard-focused="" button-renderer="true" is-icon-button="" has-no-text=""><a class="yt-simple-endpoint style-scope ytd-toggle-button-renderer" tabindex="-1"><yt-icon-button id="button" class="style-scope ytd-toggle-button-renderer style-text size-default"><!--css-build:shady--><button id="button" class="style-scope yt-icon-button" aria-label="Поставить отметку &quot;Нравится&quot;. Этот комментарий уже понравился 0 пользователям." aria-pressed="false"><yt-icon class="style-scope ytd-toggle-button-renderer"><svg viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" class="style-scope yt-icon" style="pointer-events: none; display: block; width: 100%; height: 100%;"><g class="style-scope yt-icon"><path d="M1 21h4V9H1v12zm22-11c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-1.91l-.01-.01L23 10z" class="style-scope yt-icon"></path></g></svg><!--css-build:shady--></yt-icon></button><yt-interaction id="interaction" class="circular style-scope yt-icon-button"><!--css-build:shady--><div class="stroke style-scope yt-interaction"></div><div class="fill style-scope yt-interaction"></div></yt-interaction></yt-icon-button></a></ytd-toggle-button-renderer>
      <span id="vote-count-middle" class="style-scope ytd-comment-action-buttons-renderer" hidden="">
        0
      </span>
      <ytd-toggle-button-renderer id="dislike-button" class="style-scope ytd-comment-action-buttons-renderer style-text size-default" use-keyboard-focused="" button-renderer="true" is-icon-button="" has-no-text=""><a class="yt-simple-endpoint style-scope ytd-toggle-button-renderer" tabindex="-1"><yt-icon-button id="button" class="style-scope ytd-toggle-button-renderer style-text size-default"><!--css-build:shady--><button id="button" class="style-scope yt-icon-button" aria-label="Поставить отметку &quot;Не нравится&quot;" aria-pressed="false"><yt-icon class="style-scope ytd-toggle-button-renderer"><svg viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" class="style-scope yt-icon" style="pointer-events: none; display: block; width: 100%; height: 100%;"><g class="style-scope yt-icon"><path d="M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v1.91l.01.01L1 14c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm4 0v12h4V3h-4z" class="style-scope yt-icon"></path></g></svg><!--css-build:shady--></yt-icon></button><yt-interaction id="interaction" class="circular style-scope yt-icon-button"><!--css-build:shady--><div class="stroke style-scope yt-interaction"></div><div class="fill style-scope yt-interaction"></div></yt-interaction></yt-icon-button></a></ytd-toggle-button-renderer>
      <div id="creator-heart" class="style-scope ytd-comment-action-buttons-renderer"></div>
      <div id="share-button" class="style-scope ytd-comment-action-buttons-renderer" hidden="">
      </div>
      <div id="reply-button-end" class="style-scope ytd-comment-action-buttons-renderer">
      <ytd-button-renderer class="style-scope ytd-comment-action-buttons-renderer style-text size-default" use-keyboard-focused="" button-renderer="true" is-paper-button=""><a class="yt-simple-endpoint style-scope ytd-button-renderer" tabindex="-1"><tp-yt-paper-button id="button" class="style-scope ytd-button-renderer style-text size-default" role="button" tabindex="0" animated="" elevation="0" aria-disabled="false" aria-label="Ответить"><!--css-build:shady--><yt-formatted-string id="text" class="style-scope ytd-button-renderer style-text size-default" enable-empty-style-class="">Ответить</yt-formatted-string></tp-yt-paper-button></a></ytd-button-renderer></div>
    </div>
    <div id="reply-dialog" class="style-scope ytd-comment-action-buttons-renderer"></div>
    </ytd-comment-action-buttons-renderer>
        <div id="moderation-buttons" class="style-scope ytd-comment-renderer" hidden=""></div>
        <ytd-button-renderer id="view-threaded-replies" aria-expanded="false" noink="" class="style-scope ytd-comment-renderer" use-keyboard-focused="" button-renderer="true"></ytd-button-renderer>
        <ytd-button-renderer id="hide-threaded-replies" aria-expanded="true" noink="" class="style-scope ytd-comment-renderer" use-keyboard-focused="" button-renderer="true"></ytd-button-renderer>
      </div>
    

    В этом примере имя акка с которого был коммент " Magical-Friends " в верху. А кнопка ответить почти в самом низу



  • This post is deleted!


  • Проблема решена, добрые люди помогли.
    Возможно кому то пригодиться.
    Вариант 1

    //[contains(text(),'NAME')]/../../../../../..//[@id="text"]

    Вариант 2

    //span[contains(text(),'[­[NAME]]')]/ancestor::div[contains(@id,'main')]//div[@id='reply-button-end']


Log in to reply