Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何使用Selenium和Python获取仅依赖内容(黑色)而不包含引用(蓝色)的内容_Python 3.x_Visual Studio_Selenium_Selenium Webdriver_Forum - Fatal编程技术网

Python 3.x 如何使用Selenium和Python获取仅依赖内容(黑色)而不包含引用(蓝色)的内容

Python 3.x 如何使用Selenium和Python获取仅依赖内容(黑色)而不包含引用(蓝色)的内容,python-3.x,visual-studio,selenium,selenium-webdriver,forum,Python 3.x,Visual Studio,Selenium,Selenium Webdriver,Forum,我想知道什么是得到一些内容不包括报价的内容 以下url是目标网页: 我必须使用完整的xpath来获取它们的内容。我想得到黑色的内容,我不想得到蓝色的内容,但当我使用下面的代码。我把蓝色和空白内容放在一起 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/

我想知道什么是得到一些内容不包括报价的内容

以下url是目标网页:

我必须使用完整的xpath来获取它们的内容。我想得到黑色的内容,我不想得到蓝色的内容,但当我使用下面的代码。我把蓝色和空白内容放在一起

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)
以下是他们的html代码:

<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>





有冇第隻款 我想要呢兩隻
係囉,反應好既會唔會考慮出其他?
我都想要其他


15/4/2020 13:18

我希望使用start to、not或contains指令来完成它。
有人能帮我吗?谢谢~~

不,它不起作用。终端给出的错误是
消息:选择器无效: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/text()的结果是:[对象文本]。它应该是一个元素。
Whoops!从中删除
/text()
。但是,如果我删除
text()
,我将获得所有文本。我不想收到报价文本……嗯。。。现在有点复杂了。我检查了你提供的url。它没有很多这样的评论。我只找到了一个你不想要的此类帖子。其余的都很好。因为太少了,手动删除就行了。我有100多万篇帖子。如果我手动删除它们。我需要花很多时间……不,这不起作用。终端给出的错误是
消息:选择器无效: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/text()的结果是:[对象文本]。它应该是一个元素。
Whoops!从中删除
/text()
。但是,如果我删除
text()
,我将获得所有文本。我不想收到报价文本……嗯。。。现在有点复杂了。我检查了你提供的url。它没有很多这样的评论。我只找到了一个你不想要的此类帖子。其余的都很好。因为太少了,手动删除就行了。我有100多万篇帖子。如果我手动删除它们。我需要花很多时间。。。。。。