html py网页按钮,html - python clicking a button on a webpage - Stack Overflow

When I compare the two tags I see that the difference is for the class tag.

So if you can read it then you're done

You can do it with Selenium if you like

Step 1: find the XPath

- Get the XPath of the button: for that right open the page in Chrome click on it and select Inspect element

- It will open the html file and right click on the highlighted line and select copy Xpath

- Copy the XPath in NotePad

Now that you have the XPath you can select the button via a Python script and query the attributes

Here is a prototype

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()

driver.get("http://www.youradress.org")#put here the adress of your page

elem = driver.find_elements_by_xpath("//*[@type='submit']")#put here the content you have put in Notepad, ie the XPath

button = driver.find_element_by_id('buttonID') //Or find button by ID.

print(elem.get_attribute("class"))

driver.close()

Hope that helps, if you have question please let me know

I used these links for documentation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值