AttributeError-webscraping-Python-Selenium

AttributeError-webscraping-Python-Selenium,python,selenium,web-scraping,beautifulsoup,attributeerror,Python,Selenium,Web Scraping,Beautifulsoup,Attributeerror,我需要从网上刮下下表,我无法用“查找所有”功能解决问题。这句话总是说: AttributeError: 'NoneType' object has no attribute 'find_all' 我不知道怎么了。尝试使用table.find_all(“tr”)或table.find_all(“tr”)字符和下一个属性,如table.find_all(“tr”,attrs={“class”:“table table export”})和下一个选项,但没有任何效果。 你能告诉我我做错了什么吗 表:

我需要从网上刮下下表,我无法用“查找所有”功能解决问题。这句话总是说:

AttributeError: 'NoneType' object has no attribute 'find_all'
我不知道怎么了。尝试使用table.find_all(“tr”)或table.find_all(“tr”)字符和下一个属性,如table.find_all(“tr”,attrs={“class”:“table table export”})和下一个选项,但没有任何效果。 你能告诉我我做错了什么吗

表:

<div class="table-options">
    <table class="table table-export">
                <thead>
                <tr>
                    <!-- ngIf: ActuallyPoints && ActuallyPoints.name == 'AXB' --><th ng-if="currentRole &amp;&amp; currentRole.name == 'AXB'" class="id check">
                        <label ng-click="selectAll()"><input disabled="" id="select-all" type="checkbox" ng-model="all" class="valid value-ng">All</label>
                    </th><!-- end ngIf: currentRole && currentRole.name == 'AXB' -->
                    <th>AAA</th>
                    <th>BBB</th>
                    <th>CCC</th>
        </tr>
                </thead>
                <tbody>
<!-- ngRepeat: x in ErrorStatus --><tr ng-repeat="x in ErrorStatus" class="random-id">
                    <!-- ngIf: currentRole && currentRole.name == 'AXB' --><td ng-if="currentRole &amp;&amp; currentRole.name == 'AXB'" class="random-id">
                        <input type="checkbox" ng-model="x.checked" ng-change="selectOne(x)" class="valid value-ng">
                    </td><!-- end ngIf: currentRole && currentRole.name == 'AXB' -->
                    <td class="pax">111</td>
                    <td class="pax">222</td>
                    <td class="pax">333</td>
                    </td>
                </tr><!-- end ngRepeat: x in ErrorStatus -->
                </tbody>
            </table>
        </div>

非常感谢。

我无法提供解决方案,因为没有链接,但对错误的解释非常简单:

AttributeError:'NoneType'对象没有“find\u all”属性
让我们看看您在哪里使用
。在代码中查找所有

rows=table.find_all('tr'))
考虑到解释器所说的,这段代码实际上看起来像:

rows=None.find_all('tr'))
换句话说,变量
等于
None
。因此,您的问题在于:

table=soup.find(“table”,attrs={“class”:“table-table-export”})#返回无
在人类语言中,您试图在html中查找某个表,然后将其存储到变量
table
,但是
soup.find()
无法使用您给出的指令找到元素,因此返回
None
。您没有注意到它,并尝试调用
None.find_all()
,但
None
没有此方法

这就是您收到此错误的原因。如果您无法共享此链接,请自己重新检查此链接,因为它不起作用:

table=soup.find(“table”,attrs={“class”:“table-table-export”})#返回无
UPD:首先,请尝试打印变量
soup
,并检查该表是否存在,因为您在浏览器中看到的html和您通过请求收到的html可能有很大的不同:

soup=BeautifulSoup(网站,“lxml”)
印花(汤)

您试图获取的url是什么。。请将其添加到您的代码中。很抱歉,这是一个带有机密数据库的私人url,不幸的是,我无法与所有人共享,登录是必要的。那么,我恐怕您在这里几乎得不到任何帮助。。如果其他人不能实时复制问题,那么它就不值得解决。
import lxml
from urllib.request import urlopen
from bs4 import BeautifulSoup

url = 'xxx'
website = request.urlopen(url).read()

soup = BeautifulSoup(website, "lxml")

table = soup.find("table", attrs={"class": "table table-export"})
rows = table.find_all('tr')