????????????????????????棬???????python???????????????????????е?????????????????????????????????????????????????????????????檔
?????????????????????3??
????1. ???????????????е???????????????????
????2. ??????????????“????”???????
????3. ?????????????????????????
???????????????????????????????????selenium?????????find_elements_by_tag_name????????????????????webdriver???????
????driver.find_elements_by_tag_name("a")
???????????????????a?????
???????????????е?a??????е???????????????????????????е?a??????????????涼????????п??????????????????????????????????????????????????????????????????????????
???????????
???????selenium.webdriver.remote.webelement.WebElement????get_attribute??????
???????get_attribute?????a?????????????????ж?????????????????е????
????get_attribute("href") ???a???????????????URL????URL?????ж????????????????????檔????????????????????????????????????????????·????????????????????????????????????????????????????“http”?????url??
????get_attribute("target")???target????"_blank"??????????ж????????????????????
??????????????????η???????????
????selenium webdriver ????back????????????????????driver.back()
?????????????????????????????????????????в???????????????????for loop??
????for i in range(0?? len(driver.find_elements_by_tag_name("a"))):
??????python?У???????????i??range(0?? x)????????????1?????????????0??(x-1)?????С????磺range(0??5)????[0?? 1?? 2?? 3?? 4]?????????????range??????????????range?????????????????????磺range(0??5??2)???????2??????????[0??2??4]??????С?
????????????????????????C#??foreach???????
????for targetLink in driver.find_elements_by_tag_name("a")??
????????????????????????е?a????????е?????????
?????????????????????????????????????????????

 

links = driver.find_elements_by_tag_name("a")
for link in links:
if not "_blank" in link.get_attribute("target") and ("google" in link.et_attribute("href") or not "http" in link.get_attribute("href")):
link.click()
driver.back()