You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromosimportstat,listdir,getcwd,rename,walk,listdir,remove,mkdirfromreimportcompile,search,matchfromos.pathimportsplitext,existsfromdatetimeimportdatetimefromjsonimportdump,load,loadsimportsys,iofromrandomimportrandintfromtimeimportsleepimporttimeimportrefromheliumimport*sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
importargparseclassDeleteSome(object):
def__init__(self):
# write("Hello World!")start_chrome("www.baidu.com")
#loginclick("登录")
click("用户名登录")
write("myusername", into="手机/邮箱/用户名")
write("mypwd", into="密码")
click("登录")
sleep(10)
#Suppose go to page like a "Chinese" reddit pagego_to('https://tieba.baidu.com/p/7287171441?pn=1')
url=Link("尾页").hrefprint (url,dir(url))
go_to(url)
c=find_all(S("//li[@class='d_name']"))
#filter wrong advertising tagc=[iforiincifi.web_element.text.strip()!="逍遥加速器"andi.web_element.text.strip()!="51星变"]
dddd=[i.web_element.text.strip() foriinc]
print (dddd)
#findd=find_all(S("//div[@class='core_reply_tail clearfix']"))
eee=find_all(S("//span[@class='tail-info']"))
eee=[jfori,jinenumerate(eee) ifre.search("\d{1,}楼",j.web_element.text)]
print(len(c),len(d),len(eee))#iterate tags must have same length and in same div tag#iteratefori,j,kinzip(c,d,eee):
dname=i.web_element.get_attribute('data-field')
string_flag=k.web_element.textifdname=='{"user_id":1258865446}':
sleep(2)
string_flag=k.web_element.textprint ("find tag")
print(string_flag)
#find specfic tag and deleteifLink("删除", to_left_of=string_flag).exists():
print("按钮存在")#can find but cannot click right tag#This is the issue I cant click the right delete tag with to_left_of parameter,while I can use click("删除") delete the first tag how do I use to_left_of to_right_of tag ,Documentation is not very clear.click(Link("删除",to_left_of=string_flag))
sleep(5)
click("确认")
else:
print("按钮不存在")
sleep(10)
end=Trueifend:
kill_browser()
if__name__=='__main__':
f=[]
parser=argparse.ArgumentParser(description='命令行中传入文件名')
parser.add_argument("--fname",nargs="+",default=f,help="文件名")
args=parser.parse_args()
instance=DeleteSome()
How do I get tag inside tag attribute in iteration tag?
How do I click the certain same tag with other tag when locate the tag in forloop?
The text was updated successfully, but these errors were encountered:
Suppose I have a bunch of tags in the page:
How do I get tag inside tag attribute in iteration tag?
How do I click the certain same tag with other tag when locate the tag in forloop?
The text was updated successfully, but these errors were encountered: