Jiun Jung Lin
Jiun Jung Lin

Reputation: 157

How to get only rely content(black color) and not included quote(blue color) content using Selenium and Python

I want to know what to get some content not include quote content.

The following url is the target webpage:

https://forumd.hkgolden.com/view.aspx?type=BW&message=7219211

enter image description here

I must use a full xpath to get their content. I want to get black color content and I don't want to get blue content, but when I use the following code. I got blue and blank content together.

content = driver_blank.find_element_by_xpath('/html/body/form/div[5]/div/div/div[2]/div[1]/div[5]/table[8]/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[1]/td/div')
print(content.text)

The following is their html code:

<table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 7px;">
    <tbody>
        <tr>
            <td align="left">
                <table class="repliers">
                    <tbody>
                        <tr hc7uwnfktbez9="" id="XoBTa" userid="461194" username="浅川梨奈">
                            <td class="repliers_left" style="background-color: #F3F2F1;">
                                <div>
                                    <a name="275220714"></a>
                                    <a href="javascript: ToggleUserDetail(6, 'XoBTa');" style="font-weight: bold; color: #FF0066;">
                                    浅川梨奈
                                    </a>
                                    <br>
                                    <br>
                                    <div id="ThreadUser6" style="position: relative;">
                                    <a href="/ProfilePage.aspx?userid=461194" style="text-decoration: none;">
                                    <img src="/icons/97.gif" style="border-width: 0px;" alt="Logo">
                                    </a>
                                    <br>
                                    <br>
                                    <img src="/labels/4.gif" style="border-width: 0px;" alt="Member">
                                    </div>
                                </div>
                            </td>
                            <td style="background-color: #F3F2F1; height: 100%; border: solid 1px #111111; vertical-align: top;">
                                <table class="repliers_right" cellpadding="0" cellspacing="0">
                                    <tbody>
                                        <tr>
                                            <td style="vertical-align: top;">
                                                <div class="ContentGrid">
                                                    <blockquote><div style="color: #0000A0;">有冇第隻款<img data-icons=":-[lm" src="/faces/lomore/angry.gif" alt=":-[lm"> <img data-icons=":-(lm" src="/faces/lomore/frown.gif" alt=":-(lm"> 我想要呢兩隻</div></blockquote>
                                                    <br>
                                                    係囉,反應好既會唔會考慮出其他?
                                                    <br>
                                                    我都想要其他
                                                    <img data-icons="^3^lm" src="/faces/lomore/kiss.gif" alt="^3^lm"> 
                                                    <img data-icons="[bomb]lm" src="/faces/lomore/bomb.gif" alt="[bomb]lm">
                                                    <br><br><br>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: center; vertical-align: top;">
                                                <div id="lineImage6" style="display: block; overflow: hidden;">
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="width: 100%; text-align: right;">
                                                <div style="float: right; vertical-align: bottom; margin-top: 5px;">
                                                    <div id="lauming6" style="float: left; vertical-align: bottom;"></div>&nbsp;
                                                    <a class="btn btn_small btn_bookmark" href="Javascript:bookmarkThis(7219211)" id="laumingHref">留名</a>
                                                    <a class="btn btn_small btn_complain" href="contactus.aspx?messageid=7219211&amp;replyid=275220714">投訴文章</a>
                                                    <a class="btn btn_small btn_quote" href="Javascript:QuoteReply(7219211,275220714);">快速引用</a>
                                                    <a class="btn btn_small btn_quote" href="post.aspx?mt=Y&amp;rid=275220714&amp;id=7219211&amp;page=2">引用原文</a>
                                                    <span style="font-size: 12px; color:gray;">
                                                    15/4/2020 13:18
                                                    </span>
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>

enter image description here

I hope to use start-to, not, or contains instruction to finish it. Can anyone help me? Thanks~~~

Upvotes: 1

Views: 102

Answers (0)

Related Questions