虽然我的机器上一切正常,但当我在我的服务器上运行项目时,Selenium 和 Chromedriver 无法启动,导致以下异常
2018-08-31 09:16:06,578 ERROR [stderr] (Exec Stream Pumper) /home/app.conf/homebooks2/chromedriver: 1: /home/app.conf/homebooks2/chromedriver: Syntax error: Unterminated quoted string
2018-08-31 09:16:26,570 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /crawlerClass/myCrawler/5922: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'shaula', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'i386', os.version: '3.16.0-44-generic', java.version: '1.8.0_92'
Driver info: driver.version: ChromeDriver
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at …Run Code Online (Sandbox Code Playgroud) 在我正在工作的项目中,我需要生成n个随机double数(取决于输入文件的内容)或者doubles如果我从输入文件中将它们转换为它们.逗号后面的这些数字应该只有2位小数(例如:)0.98.
我知道在Java 8中,有两种方法可以做到这一点:
nthNumber = Double.parseDouble(new DecimalFormat("#.##").format(ThreadLocalRandom.current().nextDouble(0,1)).replace(",","."));nthNumber = Double.parseDouble(new DecimalFormat("#.##").format(new Random().nextDouble()).replace(",", "."));渐渐地说,哪个是最快的?根据我对ADS的不了解,我会说它会是同一时间(O(n)?),但我并不是百分百肯定
除了这两种方式外,还有什么其他的方法来生成随机doubles之间0以及1它们更快,渐进地说,比我的建议?(相反,是否有方法可以做任何事情O(n)或O(1)?)
提前感谢所有花一分钟回答我这个问题的人
我正在尝试通过HTTP请求(感谢Python的“ requests”模块)向Instagram发出登录请求,然后将结果移植到Selenium的chromedriver,以使用户已经登录。我正在使用“ requestium ”模块尝试一下。当我通过Session成功登录到网站内部时,似乎阻止了我切换到驱动程序以拥有已登录页面的权限。这是控制台打印我的错误
DevTools listening on ws://127.0.0.1:12779/devtools/browser/73b726a1-520f-4d08-8982-a9ada65ead2b
Traceback (most recent call last):
File "requestiumTest.py", line 124, in <module>
s.transfer_session_cookies_to_driver() # You can maintain the session if needed
File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\requestium\requestium.py", line 114, in transfer_session_cookies_to_driver
'expiry': c.expires, 'domain': c.domain})
File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\requestium\requestium.py", line 235, in ensure_add_cookie
self.add_cookie(cookie)
File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 872, in add_cookie
self.execute(Command.ADD_COOKIE, {'cookie': cookie_dict})
File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Users\gforcell\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
(Session info: chrome=66.0.3359.139) …Run Code Online (Sandbox Code Playgroud)