给出以下字符串:
john<str> name2, doe<str> name1
str可以是任意长度的字符串
我想选择'
john name1, doe name2
我有以下内容:
new_string = re.sub('<.*>', '', astring, flags=re.DOTALL)
但这给了我
john name1
答案 0 :(得分:0)
在import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def click_links(driver,url):
driver.get(url)
for olink in wait.until(EC.presence_of_all_elements_located((By.CLASS_NAME, "result-row__item-hover-visualizer"))):
olink.click()
time.sleep(3)
if __name__ == '__main__':
weblink = "https://www.hitta.se/s%C3%B6k?vad=Markiser+%26+Persienner"
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
try:
click_links(driver,weblink)
finally:
driver.quit()
之后添加?
,使正则表达式变得不贪婪
*