简体   繁体   English

如何使用 python 在 Webbot 中获得 0 美元的价值

[英]How to get $0 value in Webbot using python

Please find below code am trying to get Seller Proceeds value in Website, but it has $0, when i tried in console $0.value am getting 598.08 but am getting Calculate when i tried using this sel_proc = web.find_elements(id="afn-seller-proceeds")[0].text ''' Full Code:请找到下面的代码,我试图在网站中获取卖方收益价值,但它有 0 美元,当我在控制台中尝试 $0.value 时得到598.08 ,但当我尝试使用这个sel_proc = web.find_elements(id="afn-seller-proceeds")[0].text ''' 完整代码:

import pandas as pd
from webbot import Browser
from bs4 import BeautifulSoup
web = Browser()
##web.set_window_position(-10000,0)
df = pd.read_excel('sample.xlsx')

soafees = []
fulfees = []
selproc = []
for ind in df.index:
    web.go_to('https://somelink')
##    web.set_window_position(-10000,0)
    web.click(id='link_continue')
    print("Login Successful")
    asin = df['ASIN'][ind]
    sp = int(df['Selling Price'][ind])
    print(sp)
    cp = int(df['Cost of Product'][ind])
    print(cp)
    web.type(df['ASIN'][ind] , into = 'Enter your product name, UPC, EAN, ISBN or ASIN',clear = True)
    web.click(id='a-autoid-0')
    web.type(sp,tag='input',id='afn-pricing',clear = True)
    web.type(cp,tag='input',id='afn-cost-of-goods',clear = True)
    web.click(id='update-fees-link')
    res = web.find_elements(id="afn-selling-fees")[0].text
    ful_fees = web.find_elements(id="afn-amazon-fulfillment-fees")[0].text
    sel_proc = web.find_elements(id="afn-seller-proceeds")[0].text
##    sel_proc = web.execute_script('return arguments[0].value;', element);
    print("soa fees : "+res)
    print("Fulfillment fees : "+ful_fees)
    print("Seller Proceeds : "+sel_proc)
    soafees.append(res)
    fulfees.append(ful_fees)
    selproc.append(sel_proc)
print(soafees)
print(fulfees)
print(selproc)
df_soa = pd.DataFrame(soafees,columns = ['SOA Fees'])
df_ful = pd.DataFrame(fulfees,columns = ['FBA Fees'])
df_sel = pd.DataFrame(selproc,columns = ['Seller Proceeds'])
print(df)
print(df_soa)
print(df_ful)
print(df_sel)

Snapshot for reference:快照供参考: 在此处输入图像描述

thanks in advance for your support预先感谢您的支持

In the sel_proc variable, you are storing the text, Instead, you should look for the attribute which has the value.在 sel_proc 变量中,您正在存储文本,相反,您应该查找具有该值的属性。 I believe, in this case, it should be a "value" attribute.我相信,在这种情况下,它应该是一个“价值”属性。

sel_proc = web.find_elements(id="afn-seller-proceeds")[0].get_attribute(<attribute_name>)

Your code will look something like this:您的代码将如下所示:

sel_proc = web.find_elements(id="afn-seller-proceeds")[0].get_attribute("value")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM