xpath提取多个属性值&iframe切入

1.遇见如下的html语句,class有两个属性值

可以如下操作

xpath('//div[contains(@class,"btn") and contains(@class,"btn-account")]')

2.在嵌入了frame页面的网页中直接查找位于frame页面内部的内容会出现no such element错误,解决方法如下:

driver = webdriver.chrome()
driver.get(url)
driver.switch_to.frame(frame_index_num)

拓展

driver.switch_to.frame(reference) #切入frame
driver.switch_to.parent_frame()  #返回上级frame,若已经是主文档则无效
driver.switch_to.default_content() #回主页内容

参考链接:selenium之 定位以及切换frame(iframe)

你可能感兴趣的:(爬爬PA,开发)