Selenium + ChromeDriver stuck for exactly 4 minutes
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm trying to webscrap a web page with CloudFlare protection from remote server:
#!/usr/bin/env python3
from xvfbwrapper import Xvfb
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import logging
display = Xvfb()
display.start()
try:
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger('main')
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.get('url ...')
time.sleep(10)
logger.info('woke up')
logger.info(browser.get_cookies())
finally:
display.stop()
The problem is that call of get_cookies blocking for exactly 4 minutes. Also if I'm trying to continue traverse web site I'm also stucking on every request to server for exactly 4 minutes:
root@server:~# ./s.py
2019-02-05 00:52:11,509 - main - INFO - woke up
2019-02-05 00:56:06,506 - main - INFO - [some cookies ...]
I tried to kill script while it's stuck and see that code stucks here:
root@server:~# ./s.py
2019-02-05 01:00:31,333 - main - INFO - woke up
^CTraceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./s.py", line 22, in <module>
logger.info(browser.get_cookies())
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 841, in get_cookies
return self.execute(Command.GET_ALL_COOKIES)['value']
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 66, in request
**urlopen_kw)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 87, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 321, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt
Also I tried to attach to script with strace and found out that script just blocked on getting packet from socket:
root@server:~# strace -p 7545
strace: Process 7545 attached
recvfrom(4, 0x1ec58f0, 8192, 0, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
I tried that with different versions of Chrome/Selenium and got always the same result: sticking for 4 minutes.
Ubuntu 18.04.1 LTS
Google Chrome 66.0.3359.181
ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb)
Name: selenium Version: 3.141.0
Name: xvfbwrapper Version: 0.2.9
ubuntu google-chrome selenium xvfb
add a comment |
I'm trying to webscrap a web page with CloudFlare protection from remote server:
#!/usr/bin/env python3
from xvfbwrapper import Xvfb
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import logging
display = Xvfb()
display.start()
try:
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger('main')
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.get('url ...')
time.sleep(10)
logger.info('woke up')
logger.info(browser.get_cookies())
finally:
display.stop()
The problem is that call of get_cookies blocking for exactly 4 minutes. Also if I'm trying to continue traverse web site I'm also stucking on every request to server for exactly 4 minutes:
root@server:~# ./s.py
2019-02-05 00:52:11,509 - main - INFO - woke up
2019-02-05 00:56:06,506 - main - INFO - [some cookies ...]
I tried to kill script while it's stuck and see that code stucks here:
root@server:~# ./s.py
2019-02-05 01:00:31,333 - main - INFO - woke up
^CTraceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./s.py", line 22, in <module>
logger.info(browser.get_cookies())
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 841, in get_cookies
return self.execute(Command.GET_ALL_COOKIES)['value']
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 66, in request
**urlopen_kw)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 87, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 321, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt
Also I tried to attach to script with strace and found out that script just blocked on getting packet from socket:
root@server:~# strace -p 7545
strace: Process 7545 attached
recvfrom(4, 0x1ec58f0, 8192, 0, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
I tried that with different versions of Chrome/Selenium and got always the same result: sticking for 4 minutes.
Ubuntu 18.04.1 LTS
Google Chrome 66.0.3359.181
ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb)
Name: selenium Version: 3.141.0
Name: xvfbwrapper Version: 0.2.9
ubuntu google-chrome selenium xvfb
add a comment |
I'm trying to webscrap a web page with CloudFlare protection from remote server:
#!/usr/bin/env python3
from xvfbwrapper import Xvfb
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import logging
display = Xvfb()
display.start()
try:
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger('main')
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.get('url ...')
time.sleep(10)
logger.info('woke up')
logger.info(browser.get_cookies())
finally:
display.stop()
The problem is that call of get_cookies blocking for exactly 4 minutes. Also if I'm trying to continue traverse web site I'm also stucking on every request to server for exactly 4 minutes:
root@server:~# ./s.py
2019-02-05 00:52:11,509 - main - INFO - woke up
2019-02-05 00:56:06,506 - main - INFO - [some cookies ...]
I tried to kill script while it's stuck and see that code stucks here:
root@server:~# ./s.py
2019-02-05 01:00:31,333 - main - INFO - woke up
^CTraceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./s.py", line 22, in <module>
logger.info(browser.get_cookies())
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 841, in get_cookies
return self.execute(Command.GET_ALL_COOKIES)['value']
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 66, in request
**urlopen_kw)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 87, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 321, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt
Also I tried to attach to script with strace and found out that script just blocked on getting packet from socket:
root@server:~# strace -p 7545
strace: Process 7545 attached
recvfrom(4, 0x1ec58f0, 8192, 0, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
I tried that with different versions of Chrome/Selenium and got always the same result: sticking for 4 minutes.
Ubuntu 18.04.1 LTS
Google Chrome 66.0.3359.181
ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb)
Name: selenium Version: 3.141.0
Name: xvfbwrapper Version: 0.2.9
ubuntu google-chrome selenium xvfb
I'm trying to webscrap a web page with CloudFlare protection from remote server:
#!/usr/bin/env python3
from xvfbwrapper import Xvfb
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import logging
display = Xvfb()
display.start()
try:
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger('main')
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.get('url ...')
time.sleep(10)
logger.info('woke up')
logger.info(browser.get_cookies())
finally:
display.stop()
The problem is that call of get_cookies blocking for exactly 4 minutes. Also if I'm trying to continue traverse web site I'm also stucking on every request to server for exactly 4 minutes:
root@server:~# ./s.py
2019-02-05 00:52:11,509 - main - INFO - woke up
2019-02-05 00:56:06,506 - main - INFO - [some cookies ...]
I tried to kill script while it's stuck and see that code stucks here:
root@server:~# ./s.py
2019-02-05 01:00:31,333 - main - INFO - woke up
^CTraceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./s.py", line 22, in <module>
logger.info(browser.get_cookies())
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 841, in get_cookies
return self.execute(Command.GET_ALL_COOKIES)['value']
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 66, in request
**urlopen_kw)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 87, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 321, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
KeyboardInterrupt
Also I tried to attach to script with strace and found out that script just blocked on getting packet from socket:
root@server:~# strace -p 7545
strace: Process 7545 attached
recvfrom(4, 0x1ec58f0, 8192, 0, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
I tried that with different versions of Chrome/Selenium and got always the same result: sticking for 4 minutes.
Ubuntu 18.04.1 LTS
Google Chrome 66.0.3359.181
ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb)
Name: selenium Version: 3.141.0
Name: xvfbwrapper Version: 0.2.9
ubuntu google-chrome selenium xvfb
ubuntu google-chrome selenium xvfb
asked Feb 4 at 22:15
Edvard DavtyanEdvard Davtyan
61
61
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1402024%2fselenium-chromedriver-stuck-for-exactly-4-minutes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1402024%2fselenium-chromedriver-stuck-for-exactly-4-minutes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown