GVKun编程网logo

AttributeError:使用Selenium和Python,“列表”对象没有属性“点击”(python对象没有这个属性)

9

最近很多小伙伴都在问AttributeError:使用Selenium和Python,“列表”对象没有属性“点击”和python对象没有这个属性这两个问题,那么本篇文章就来给大家详细解答一下,同时本文

最近很多小伙伴都在问AttributeError:使用Selenium和Python,“列表”对象没有属性“点击”python对象没有这个属性这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展AttributeError:“ numpy.float64”对象没有属性“ log10”、AttributeError:“ numpy.ndarray”对象没有属性“ set_aspect”、AttributeError:“ OAuthConsumer”对象没有属性“回调”、AttributeError:“ PerReplica”对象没有属性“ numpy”等相关知识,下面开始了哦!

本文目录一览:

AttributeError:使用Selenium和Python,“列表”对象没有属性“点击”(python对象没有这个属性)

AttributeError:使用Selenium和Python,“列表”对象没有属性“点击”(python对象没有这个属性)

我想在默认设置为“季度”的页面上单击“年度”按钮。有两个基本上相同的链接,除了一个链接,data-ptype="Annual"所以我试图复制xpath来单击按钮(也尝试了其他选项,但没有一个起作用)。

但是,我得到了AttributeError: ''list'' object has no attribute''click''。我读了很多类似的文章,但无法解决我的问题..因此,我认为必须调用/单击/执行javascript事件以某种方式不同。

from selenium import webdriverlink = ''https://www.investing.com/equities/apple-computer-inc-balance-sheet''driver = webdriver.Firefox()driver.get(link)elm = driver.find_elements_by_xpath("/html/body/div[5]/section/div[8]/div[1]/a[1]").click()

html如下:

<ahref="javascript:void(0);" data-type="rf-type-button" data-ptype="Annual" data-pid="6408" data-rtype="BAL">..</a>

答案1

小编典典

我仍然建议您通过 XPATH* 使用 linkText 。原因xpath:是绝对的,如果 从HTML中 添加
删除了 另一个div ,则可能会失败。而更改链接文本的机会非常小。
/html/body/div[5]/section/div[8]/div[1]/a[1] *****

因此,代替此 代码

elm = driver.find_elements_by_xpath("/html/body/div[5]/section/div[8]/div[1]/a[1]").click()

试试这个代码:

annual_link = driver.find_element_by_link_text(''Annual'')annual_link.click()

是的@Druta是正确的,find_element用于一个Web元素和Web元素find_elements列表。拥有总是很好explicitwait

创建显式等待的实例,如下所示:

wait = WebDriverWait(driver,20)

并使用如下的等待引用:

wait.until(EC.elementToBeClickable(By.LINK_TEXT, ''Annual''))

更新:

from selenium import webdriverlink = ''https://www.investing.com/equities/apple-computer-inc-balance-sheet''driver = webdriver.Firefox()driver.maximize_window()wait = WebDriverWait(driver,40)driver.get(link)driver.execute_script("window.scrollTo(0, 200)")wait.until(EC.element_to_be_clickable((By.LINK_TEXT, ''Annual'')))annual_link = driver.find_element_by_link_text(''Annual'')annual_link.click()print(annual_link.text)

确保导入这些:

from selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as EC

AttributeError:“ numpy.float64”对象没有属性“ log10”

AttributeError:“ numpy.float64”对象没有属性“ log10”

我正在尝试使用sklearn.LinearRegression查找大量短序列的对数斜率。数据是从熊猫数据帧的行中提取的,如下所示:

bp01    1.12
bp02    1.12
bp03    1.08
bp04    0.99
bp05    1.08
bp06    1.19
bp07    1.17
bp08    1.05
bp09     0.8
bp10    0.96
bp11    0.97
bp12    1.12
bp13    0.91
bp14    0.96
bp15    1.05
bp16    0.93
bp17    0.97
bp18    0.92
bp19    0.89
bp20       0
Name: 42029,dtype: object

但是,当我尝试使用np.log10时,在该系列上出现以下错误:

In[27]: test.apply(np.log10)
Traceback (most recent call last):

  File "<ipython-input-27-bccff3ed525b>",line 1,in <module>
    test.apply(np.log10)

  File "C:\location",line 2348,in apply
    return f(self)

AttributeError: 'numpy.float64' object has no attribute 'log10'

我不确定为什么会出现此错误,根据我所看到的,np.log10是否可以与numpy.float64一起使用。有想法吗?

AttributeError:“ numpy.ndarray”对象没有属性“ set_aspect”

AttributeError:“ numpy.ndarray”对象没有属性“ set_aspect”

如何解决AttributeError:“ numpy.ndarray”对象没有属性“ set_aspect”?

当我编写代码时:

for i in iaq:

fig,ax = plt.subplots(8,5,figsize=(8,5))
df_g2[df_g2[''aq_date''] == i].plot(column=''zone_id'',cmap=''Greens'',ax=ax,legend=True)
ax.set_title(''Analysis :''+ str(i))
plt.show()

它显示以下错误:

AttributeError: ''numpy.ndarray'' object has no attribute ''set_aspect''

如何解决这个问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

AttributeError:“ OAuthConsumer”对象没有属性“回调”

AttributeError:“ OAuthConsumer”对象没有属性“回调”

如何解决AttributeError:“ OAuthConsumer”对象没有属性“回调”?

我正在尝试对Twitter API使用oauth:但是此错误经常弹出

import urllib.parse as urlparse
from oauth import oauth
from twitter_scrapper import hidden


def augment(url,parameters):
    secrets = hidden.oauth()
    consumer = oauth.OAuthConsumer(secrets["consumer_key"],secrets["consumer_secret"])
    token = oauth.OAuthConsumer(secrets["token_key"],secrets["token_secret"])

    oauth_request = oauth.OAuthRequest.from_consumer_and_token(consumer,token=token,http_method="GET",http_url=url,parameters=parameters)
    oauth_request.sign_request(oauth.OAuthSignatureMethod_HMAC_SHA1(),consumer,token)
    return oauth_request.to_url()

输出:

''OAuthConsumer'' object has no attribute ''callback''

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

AttributeError:“ PerReplica”对象没有属性“ numpy”

AttributeError:“ PerReplica”对象没有属性“ numpy”

我目前正在使用相同的仓库,并遇到此错误。不幸的是我还没有修复,但是与此同时我正在使用变通方法。培训尝试评估网络时,将引发此错误。它每隔x次迭代执行一次此操作,具体取决于您在文件“ ./examples/fastspeech2/conf/fastspeech2.v1.yaml”中将eval_internal_steps设置为什么。如果将此数字增加到大于train_max_steps,则永远不会调用引发错误的函数。

引发此错误的函数是generate_and_save_intermediate_result(batch),据我所知,您可以在没有该函数的情况下进行训练。

今天关于AttributeError:使用Selenium和Python,“列表”对象没有属性“点击”python对象没有这个属性的介绍到此结束,谢谢您的阅读,有关AttributeError:“ numpy.float64”对象没有属性“ log10”、AttributeError:“ numpy.ndarray”对象没有属性“ set_aspect”、AttributeError:“ OAuthConsumer”对象没有属性“回调”、AttributeError:“ PerReplica”对象没有属性“ numpy”等更多相关知识的信息可以在本站进行查询。

本文标签: