编程语言
首页 > 编程语言> > python+win32+ie浏览器操作 TypeError: getElementById() takes exactly 1 argument (2 given)

python+win32+ie浏览器操作 TypeError: getElementById() takes exactly 1 argument (2 given)

作者:互联网

 

使用body操作

# -*- coding:UTF-8 -*-
 
import win32com.client
from time import sleep
 
 
 
second=win32com.client.DispatchEx("InternetExplorer.Application")
second.Navigate('http://passport.cnblogs.com/login.aspx')
second.Visible=1
while second.Busy:
    sleep(1)
 
doc=second.Document
body=doc.body
#doc.getElementById("login")
 
for i in body.getElementsByTagName("input"):
    if i.id=='input1':
        i.value='13816407285'
    if i.id=='input2':
        i.value='59459540a'
 
for i in body.getElementsByTagName("input"):
    if i.id=='signin':
        i.click()
        print('click')

 

标签:body,given,TypeError,takes,doc,click,second,sleep,id
来源: https://www.cnblogs.com/sea-stream/p/10362601.html