升级set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
echo hour=%hour%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
echo min=%min%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
echo secs=%secs%
set year=%date:~-4%
echo year=%year%
set dt=%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hour%%min%%secs%
set filename=%1
bcp TABLE.dbo.%1 OUT C:\temp\%filename%_%dt%.dat -n -T
和firefox
后,我遇到了一些代码问题
我对selenium
python
import sys
import time
import getopt
import urllib
import selenium
from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
class Scrape:
display = None
driver = None
def __init__(self):
# Start display
self.display = Display(visible=0, size=(800, 600))
self.display.start()
# Init args
query = ''
try:
opts, args = getopt.getopt(sys.argv[1:], '', ['query=','proxy='])
for opt, arg in opts:
if opt == '--query':
query = arg
except getopt.GetoptError as err:
self.error(str(err))
# Init driver
try:
self.driver = webdriver.Firefox()
self.driver.wait = WebDriverWait(self.driver, 5)
except selenium.common.exceptions.WebDriverException as err:
self.error(str(err))
print('teeeesting...!')
def error(self, str):
self.close()
print>>sys.stderr, str
sys.exit(1)
def close(self):
self.driver.quit()
self.display.stop()
if __name__ == '__main__':
Scrape()
答案 0 :(得分:1)
事件的顺序似乎是:
error
。error
名为close
。close
尝试来呼叫quit
,但self
(您的驱动程序)的值为None
...没有方法名为quit
。因此最终的错误追溯。插入一些策略性print
命令来跟踪您的驱动程序是否已初始化(我不希望)。可能的位置在Init driver
下的异常处理程序中:打印您引发的异常,并且可能围绕该问题有一两个有用的值。