正在填充用户名,但是只有当我用鼠标物理地单击用户名字段后,该按钮才起作用。...
from Tkinter import *
import subprocess
import shlex
import os
import time
import string
import threading
import sys, argparse
import ttk
from openpyxl import Workbook, load_workbook
from openpyxl.compat import range
from openpyxl.utils import get_column_letter
from openpyxl.styles import Alignment, PatternFill, Border, Color
from openpyxl.styles.colors import YELLOW
from openpyxl.styles.borders import Border, Side
import re
import logging
import warnings
import os.path
import gzip
#import xlwt
#import xlrd
readstructfile = None
filename = None
structnames = []
filename_and_structnames_l = []
global found_struct
global found_struct_idx
found_struct_idx = {}
found_struct = 0
def readfileanddump(filename_and_structnames):
global found_struct
filename_and_structnames_l = filename_and_structnames.split(",")
if len(filename_and_structnames_l) < 2:
filename = filename_and_structnames_l[0]
structnames.append('all')
print "1. Value of filename %s and structnames %s"%(filename, str(structnames))
elif len(filename_and_structnames_l) > 1 and len(filename_and_structnames_l) < 3:
filename = filename_and_structnames_l[0]
structnames.append(filename_and_structnames_l[1])
print "2. Value of filename %s and structnames %s"%(filename, str(structnames))
elif len(filename_and_structnames_l) > 2:
filename = filename_and_structnames_l[0]
for i in range (1, len(filename_and_structnames_l)):
structnames.append(filename_and_structnames_l[i])
print "3. Value of filename %s and structnames %s"%(filename, str(structnames))
if (len(structnames) == 1) and (structnames[0] == 'all'):
readstructfile = open(filename, "r+")
test_str = readstructfile.readlines()
matches = re.finditer(r"\{(.*?)\}", str(test_str), re.MULTILINE | re.DOTALL)
for matchNum, match in enumerate(matches):
for groupNum in range(0, len(match.groups())):
print (match.group(1))
# match_group_t = str(str(re.sub('[A-Za-z0-9_[]:]+', '', str(match.group(1)))).strip())
# match_group_t = match.groups(1)
#for i in range (len(match_group_t)):
# print match_group_t[i].replace("\n","")
# print str(str(re.sub('[^A-Za-z0-9[:]]+[\r\n]+', ' ', str(match_group_t[i]))))
# print re.sub(r"(?<=[a-z])\r?\n"," ", match_group_t[i])
# print ''.join(ch for ch in match_group_t[i] if not ch.isspace())
# print ''.join(match_group_t[i].strip().split())
#print(re.sub(r"(?:[;\n']|\s{2,})",r'',match_group_t[i])[2:])
# print match_group_t
print(re.sub(r"(?:[;\n']|\s{2,})",r'',match.group(1))[2:])
else:
readstructfile = open(filename, "r+")
for lines in readstructfile:
if found_struct == 0 and re.match(r'.*typedef struct', lines):
found_struct = 1
matches = re.finditer(r"\{(.*?)\}.*", str(lines), re.MULTILINE | re.DOTALL)
print "Value in matches", matches
if found_struct == 1 and re.match(r'.*}.*', lines):
found_struct = 0
found_struct_t = str(str(re.sub('[^A-Za-z0-9_]+', ' ', str(lines))).strip()).split(" ")
for i in range (len(structnames)):
if structnames[i] == found_struct_t[0]:
# print "value of found_struct_t", found_struct_t
# #found_struct_idx.append(found_struct_t[0])
# found_struct_idx[structnames[i]] = i
# print "Value of found_struct_idx", found_struct_idx
# break
print "Value in found_struct_t", found_struct_t
# for matchNum, match in enumerate(matches):
# for groupNum in range(0, len(match.groups())):
# print (match.group(1))
readfileanddump('alldetailspkg');
网站登录页面https://www.britishgas.co.uk/identity/
HTML如下
HTMLDoc.getElementById("loginForm-email").Focus
HTMLDoc.getElementById("loginForm-email").Click
HTMLDoc.getElementById("loginForm-email").Value = "A Username"
HTMLDoc.getElementById("loginForm-next").Focus
HTMLDoc.getElementById("loginForm-next").Click
HTML的结尾
答案 0 :(得分:0)
以下内容对我有用,尽管使用虚构信息会提示您提供更多信息:
Option Explicit
Public Sub GetInfo()
Dim IE As New InternetExplorer
With IE
.Visible = True
.navigate "https://www.britishgas.co.uk/identity/"
While .Busy Or .readyState < 4: DoEvents: Wend
With .document.getElementById("loginForm-email")
.Focus
.Value = "joe.bloggs@internet.com"
End With
Application.Wait Now + TimeSerial(0, 0, 1)
With .document.getElementById("loginForm-next")
.Focus
.Click
End With
'.Quit
End With
End Sub