当我的Selenium程序由于某些错误而崩溃时,它似乎留着正在运行的进程。
例如,这是我的流程列表:
carol 30186 0.0 0.0 103576 7196 pts/11 Sl 00:45 0:00 /home/carol/test/chromedriver --port=51789
carol 30322 0.0 0.0 102552 7160 pts/11 Sl 00:45 0:00 /home/carol/test/chromedriver --port=33409
carol 30543 0.0 0.0 102552 7104 pts/11 Sl 00:48 0:00 /home/carol/test/chromedriver --port=42567
carol 30698 0.0 0.0 102552 7236 pts/11 Sl 00:50 0:00 /home/carol/test/chromedriver --port=46590
carol 30938 0.0 0.0 102552 7496 pts/11 Sl 00:55 0:00 /home/carol/test/chromedriver --port=51930
carol 31546 0.0 0.0 102552 7376 pts/11 Sl 01:16 0:00 /home/carol/test/chromedriver --port=53077
carol 31549 0.5 0.0 0 0 …Run Code Online (Sandbox Code Playgroud) python selenium python-2.7 selenium-chromedriver selenium-webdriver
我正在尝试匹配模式:
<--Header Title-->
some body text
Run Code Online (Sandbox Code Playgroud)
以下仅匹配第一次出现的情况:
string1 = """<-- Option 1 -->
Nice text
<--Final stuff-->
Listing all
of
the
text
"""
regex = re.compile(r"<--([\w\s]+)-->([\s\S]*?)(?=\n<--|$)")
m = regex.search(string1)
print m.groups()
Run Code Online (Sandbox Code Playgroud)
结果是:
(' Option 1 ', '\nNice text')
Run Code Online (Sandbox Code Playgroud)
但是,使用pythex似乎可以正常工作。
我究竟做错了什么?