我正试图在销售模块下隐藏此按钮。所以这是原始代码:
url = "https://foursquare.com/v/pantai-klebang/4c7c12d22d3ba14318e595d0"
r = requests.get(url)
soup = BeautifulSoup(r.content, "html.parser")
containers = soup.findAll("li", {"class": "tip"})
filename = "review.csv"
f = open(filename, 'w')
for container in containers:
review = container.find("div", {"class": "tipText"}).text
print(review.decode('unicode_escape').encode('ascii','ignore'))
所以我继承了视图并创建了这段代码:
<button name="%(action_view_sale_advance_payment_inv)d"
string="Create Invoice"
type="action" class="btn-primary"
attrs="{'invisible': [('invoice_status', '!=', 'to invoice')]}"/>
但是在运行此代码时出现此错误:
<xpath name="//header/button[@name='%(sale.action_view_sale_advance_payment_inv)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
请帮忙。感谢。
答案 0 :(得分:1)
您写的name
代替expr
作为xpath
的属性:
<xpath expr="//header/button[@name='%(sale.action_view_sale_advance_payment_inv)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
这应该是问题。