跳到主要内容

playwright

· 阅读需 10 分钟

https://blog.csdn.net/zhangkezkzk/article/details/125947708

https://pypi.org/

https://playwright.dev/python/docs/intro

  1. 安装 Pytest plugin
pip install pytest-playwright
  1. 安装要求的浏览器
playwright install
(base) mjl@ubuntu:~$ conda create -n crawl-playwright python=3.8
Retrieving notices: ...working... done
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /home/mjl/miniconda3/envs/crawl-playwright

added / updated specs:
- python=3.8


The following NEW packages will be INSTALLED:

_libgcc_mutex anaconda/pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex anaconda/pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu
ca-certificates anaconda/pkgs/main/linux-64::ca-certificates-2023.05.30-h06a4308_0
ld_impl_linux-64 anaconda/pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1
libffi anaconda/pkgs/main/linux-64::libffi-3.4.4-h6a678d5_0
libgcc-ng anaconda/pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1
libgomp anaconda/pkgs/main/linux-64::libgomp-11.2.0-h1234567_1
libstdcxx-ng anaconda/pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1
ncurses anaconda/pkgs/main/linux-64::ncurses-6.4-h6a678d5_0
openssl anaconda/pkgs/main/linux-64::openssl-3.0.10-h7f8727e_0
pip anaconda/pkgs/main/linux-64::pip-23.2.1-py38h06a4308_0
python anaconda/pkgs/main/linux-64::python-3.8.17-h955ad1f_0
readline anaconda/pkgs/main/linux-64::readline-8.2-h5eee18b_0
setuptools anaconda/pkgs/main/linux-64::setuptools-68.0.0-py38h06a4308_0
sqlite anaconda/pkgs/main/linux-64::sqlite-3.41.2-h5eee18b_0
tk anaconda/pkgs/main/linux-64::tk-8.6.12-h1ccaba5_0
wheel anaconda/pkgs/main/linux-64::wheel-0.38.4-py38h06a4308_0
xz anaconda/pkgs/main/linux-64::xz-5.4.2-h5eee18b_0
zlib anaconda/pkgs/main/linux-64::zlib-1.2.13-h5eee18b_0


Proceed ([y]/n)? y


Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate crawl-playwright
#
# To deactivate an active environment, use
#
# $ conda deactivate

(crawl-playwright) mjl@ubuntu:~$ pip install pytest-playwright
Collecting pytest-playwright
Obtaining dependency information for pytest-playwright from https://files.pythonhosted.org/packages/2b/cc/ca315a9937889fac9485bd6efd9f9931ca70674212fc10606895c5673d82/pytest_playwright-0.4.2-py3-none-any.whl.metadata
Downloading pytest_playwright-0.4.2-py3-none-any.whl.metadata (1.5 kB)
Collecting playwright>=1.18 (from pytest-playwright)
Obtaining dependency information for playwright>=1.18 from https://files.pythonhosted.org/packages/bb/1a/82cb85c0ac5d40f3dfbb6e3d9247d8fd302f5de639b0321bde9336702043/playwright-1.36.0-py3-none-manylinux1_x86_64.whl.metadata
Using cached playwright-1.36.0-py3-none-manylinux1_x86_64.whl.metadata (3.5 kB)
Collecting pytest<8.0.0,>=6.2.4 (from pytest-playwright)
Obtaining dependency information for pytest<8.0.0,>=6.2.4 from https://files.pythonhosted.org/packages/33/b2/741130cbcf2bbfa852ed95a60dc311c9e232c7ed25bac3d9b8880a8df4ae/pytest-7.4.0-py3-none-any.whl.metadata
Downloading pytest-7.4.0-py3-none-any.whl.metadata (8.0 kB)
Collecting pytest-base-url<3.0.0,>=1.0.0 (from pytest-playwright)
Downloading pytest_base_url-2.0.0-py3-none-any.whl (4.6 kB)
Collecting python-slugify<9.0.0,>=6.0.0 (from pytest-playwright)
Downloading python_slugify-8.0.1-py2.py3-none-any.whl (9.7 kB)
Collecting greenlet==2.0.2 (from playwright>=1.18->pytest-playwright)
Using cached greenlet-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (618 kB)
Collecting pyee==9.0.4 (from playwright>=1.18->pytest-playwright)
Downloading pyee-9.0.4-py2.py3-none-any.whl (14 kB)
Collecting typing-extensions (from playwright>=1.18->pytest-playwright)
Obtaining dependency information for typing-extensions from https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl.metadata
Downloading typing_extensions-4.7.1-py3-none-any.whl.metadata (3.1 kB)
Collecting iniconfig (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Downloading iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting packaging (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Downloading packaging-23.1-py3-none-any.whl (48 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 295.8 kB/s eta 0:00:00
Collecting pluggy<2.0,>=0.12 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Obtaining dependency information for pluggy<2.0,>=0.12 from https://files.pythonhosted.org/packages/51/32/4a79112b8b87b21450b066e102d6608907f4c885ed7b04c3fdb085d4d6ae/pluggy-1.2.0-py3-none-any.whl.metadata
Downloading pluggy-1.2.0-py3-none-any.whl.metadata (4.4 kB)
Collecting exceptiongroup>=1.0.0rc8 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Obtaining dependency information for exceptiongroup>=1.0.0rc8 from https://files.pythonhosted.org/packages/fe/17/f43b7c9ccf399d72038042ee72785c305f6c6fdc6231942f8ab99d995742/exceptiongroup-1.1.2-py3-none-any.whl.metadata
Downloading exceptiongroup-1.1.2-py3-none-any.whl.metadata (6.1 kB)
Collecting tomli>=1.0.0 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Downloading tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting requests>=2.9 (from pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for requests>=2.9 from https://files.pythonhosted.org/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl.metadata
Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting text-unidecode>=1.3 (from python-slugify<9.0.0,>=6.0.0->pytest-playwright)
Downloading text_unidecode-1.3-py2.py3-none-any.whl (78 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.2/78.2 kB 45.4 kB/s eta 0:00:00
Collecting charset-normalizer<4,>=2 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for charset-normalizer<4,>=2 from https://files.pythonhosted.org/packages/cb/e7/5e43745003bf1f90668c7be23fc5952b3a2b9c2558f16749411c18039b36/charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Downloading charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (31 kB)
Collecting idna<4,>=2.5 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Downloading idna-3.4-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 54.2 kB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for urllib3<3,>=1.21.1 from https://files.pythonhosted.org/packages/9b/81/62fd61001fa4b9d0df6e31d47ff49cfa9de4af03adecf339c7bc30656b37/urllib3-2.0.4-py3-none-any.whl.metadata
Downloading urllib3-2.0.4-py3-none-any.whl.metadata (6.6 kB)
Collecting certifi>=2017.4.17 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for certifi>=2017.4.17 from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata
Downloading certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Downloading pytest_playwright-0.4.2-py3-none-any.whl (10 kB)
Downloading playwright-1.36.0-py3-none-manylinux1_x86_64.whl (35.3 MB)
━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.6/35.3 MB 24.6 kB/s eta 0:17:23
ERROR: Exception:
Traceback (most recent call last):
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
yield
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 561, in read
data = self._fp_read(amt) if not fp_closed else b""
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 90, in read
data = self.__fp.read(amt)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/http/client.py", line 459, in read
n = self.readinto(b)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/http/client.py", line 503, in readinto
n = self.fp.readinto(b)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 248, in wrapper
return func(self, options, args)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 377, in run
requirement_set = resolver.resolve(
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 161, in resolve
self.factory.preparer.prepare_linked_requirements_more(reqs)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 565, in prepare_linked_requirements_more
self._complete_partial_requirements(
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 479, in _complete_partial_requirements
for link, (filepath, _) in batch_download:
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/network/download.py", line 183, in __call__
for chunk in chunks:
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 53, in _rich_progress_bar
for chunk in iterable:
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/network/utils.py", line 63, in response_chunks
for chunk in response.raw.stream(
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 622, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 587, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 443, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
(crawl-playwright) mjl@ubuntu:~$ pip install playwright-1.36.0-py3-none-manylinux1_x86_64.whl 
Processing ./playwright-1.36.0-py3-none-manylinux1_x86_64.whl
Collecting greenlet==2.0.2 (from playwright==1.36.0)
Using cached greenlet-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (618 kB)
Collecting pyee==9.0.4 (from playwright==1.36.0)
Using cached pyee-9.0.4-py2.py3-none-any.whl (14 kB)
Collecting typing-extensions (from playwright==1.36.0)
Obtaining dependency information for typing-extensions from https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl.metadata
Using cached typing_extensions-4.7.1-py3-none-any.whl.metadata (3.1 kB)
Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Installing collected packages: typing-extensions, greenlet, pyee, playwright
Successfully installed greenlet-2.0.2 playwright-1.36.0 pyee-9.0.4 typing-extensions-4.7.1
(crawl-playwright) mjl@ubuntu:~$ pip install pytest-playwright
Collecting pytest-playwright
Obtaining dependency information for pytest-playwright from https://files.pythonhosted.org/packages/2b/cc/ca315a9937889fac9485bd6efd9f9931ca70674212fc10606895c5673d82/pytest_playwright-0.4.2-py3-none-any.whl.metadata
Using cached pytest_playwright-0.4.2-py3-none-any.whl.metadata (1.5 kB)
Requirement already satisfied: playwright>=1.18 in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from pytest-playwright) (1.36.0)
Collecting pytest<8.0.0,>=6.2.4 (from pytest-playwright)
Obtaining dependency information for pytest<8.0.0,>=6.2.4 from https://files.pythonhosted.org/packages/33/b2/741130cbcf2bbfa852ed95a60dc311c9e232c7ed25bac3d9b8880a8df4ae/pytest-7.4.0-py3-none-any.whl.metadata
Using cached pytest-7.4.0-py3-none-any.whl.metadata (8.0 kB)
Collecting pytest-base-url<3.0.0,>=1.0.0 (from pytest-playwright)
Using cached pytest_base_url-2.0.0-py3-none-any.whl (4.6 kB)
Collecting python-slugify<9.0.0,>=6.0.0 (from pytest-playwright)
Using cached python_slugify-8.0.1-py2.py3-none-any.whl (9.7 kB)
Requirement already satisfied: greenlet==2.0.2 in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from playwright>=1.18->pytest-playwright) (2.0.2)
Requirement already satisfied: pyee==9.0.4 in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from playwright>=1.18->pytest-playwright) (9.0.4)
Requirement already satisfied: typing-extensions in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from playwright>=1.18->pytest-playwright) (4.7.1)
Collecting iniconfig (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting packaging (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting pluggy<2.0,>=0.12 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Obtaining dependency information for pluggy<2.0,>=0.12 from https://files.pythonhosted.org/packages/51/32/4a79112b8b87b21450b066e102d6608907f4c885ed7b04c3fdb085d4d6ae/pluggy-1.2.0-py3-none-any.whl.metadata
Using cached pluggy-1.2.0-py3-none-any.whl.metadata (4.4 kB)
Collecting exceptiongroup>=1.0.0rc8 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Obtaining dependency information for exceptiongroup>=1.0.0rc8 from https://files.pythonhosted.org/packages/fe/17/f43b7c9ccf399d72038042ee72785c305f6c6fdc6231942f8ab99d995742/exceptiongroup-1.1.2-py3-none-any.whl.metadata
Using cached exceptiongroup-1.1.2-py3-none-any.whl.metadata (6.1 kB)
Collecting tomli>=1.0.0 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting requests>=2.9 (from pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for requests>=2.9 from https://files.pythonhosted.org/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl.metadata
Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting text-unidecode>=1.3 (from python-slugify<9.0.0,>=6.0.0->pytest-playwright)
Using cached text_unidecode-1.3-py2.py3-none-any.whl (78 kB)
Collecting charset-normalizer<4,>=2 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for charset-normalizer<4,>=2 from https://files.pythonhosted.org/packages/cb/e7/5e43745003bf1f90668c7be23fc5952b3a2b9c2558f16749411c18039b36/charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Using cached charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (31 kB)
Collecting idna<4,>=2.5 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for urllib3<3,>=1.21.1 from https://files.pythonhosted.org/packages/9b/81/62fd61001fa4b9d0df6e31d47ff49cfa9de4af03adecf339c7bc30656b37/urllib3-2.0.4-py3-none-any.whl.metadata
Using cached urllib3-2.0.4-py3-none-any.whl.metadata (6.6 kB)
Collecting certifi>=2017.4.17 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for certifi>=2017.4.17 from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata
Using cached certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Using cached pytest_playwright-0.4.2-py3-none-any.whl (10 kB)
Downloading pytest-7.4.0-py3-none-any.whl (323 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 323.6/323.6 kB 30.1 kB/s eta 0:00:00
Downloading exceptiongroup-1.1.2-py3-none-any.whl (14 kB)
Downloading pluggy-1.2.0-py3-none-any.whl (17 kB)
Downloading requests-2.31.0-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 32.3 kB/s eta 0:00:00
Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 kB 17.6 kB/s eta 0:00:00
Downloading charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/199.1 kB ? eta -:--:--
ERROR: Exception:
Traceback (most recent call last):
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 438, in _error_catcher
yield
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 561, in read
data = self._fp_read(amt) if not fp_closed else b""
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 527, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 90, in read
data = self.__fp.read(amt)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/http/client.py", line 459, in read
n = self.readinto(b)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/http/client.py", line 503, in readinto
n = self.fp.readinto(b)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 248, in wrapper
return func(self, options, args)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 377, in run
requirement_set = resolver.resolve(
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 161, in resolve
self.factory.preparer.prepare_linked_requirements_more(reqs)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 565, in prepare_linked_requirements_more
self._complete_partial_requirements(
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 479, in _complete_partial_requirements
for link, (filepath, _) in batch_download:
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/network/download.py", line 183, in __call__
for chunk in chunks:
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 53, in _rich_progress_bar
for chunk in iterable:
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_internal/network/utils.py", line 63, in response_chunks
for chunk in response.raw.stream(
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 622, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 587, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/home/mjl/miniconda3/envs/crawl-playwright/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 443, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
(crawl-playwright) mjl@ubuntu:~$ pip install charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl 
Processing ./charset_normalizer-3.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Installing collected packages: charset-normalizer
Successfully installed charset-normalizer-3.2.0
(crawl-playwright) mjl@ubuntu:~$ pip install pytest-playwright
Collecting pytest-playwright
Obtaining dependency information for pytest-playwright from https://files.pythonhosted.org/packages/2b/cc/ca315a9937889fac9485bd6efd9f9931ca70674212fc10606895c5673d82/pytest_playwright-0.4.2-py3-none-any.whl.metadata
Using cached pytest_playwright-0.4.2-py3-none-any.whl.metadata (1.5 kB)
Requirement already satisfied: playwright>=1.18 in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from pytest-playwright) (1.36.0)
Collecting pytest<8.0.0,>=6.2.4 (from pytest-playwright)
Obtaining dependency information for pytest<8.0.0,>=6.2.4 from https://files.pythonhosted.org/packages/33/b2/741130cbcf2bbfa852ed95a60dc311c9e232c7ed25bac3d9b8880a8df4ae/pytest-7.4.0-py3-none-any.whl.metadata
Using cached pytest-7.4.0-py3-none-any.whl.metadata (8.0 kB)
Collecting pytest-base-url<3.0.0,>=1.0.0 (from pytest-playwright)
Using cached pytest_base_url-2.0.0-py3-none-any.whl (4.6 kB)
Collecting python-slugify<9.0.0,>=6.0.0 (from pytest-playwright)
Using cached python_slugify-8.0.1-py2.py3-none-any.whl (9.7 kB)
Requirement already satisfied: greenlet==2.0.2 in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from playwright>=1.18->pytest-playwright) (2.0.2)
Requirement already satisfied: pyee==9.0.4 in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from playwright>=1.18->pytest-playwright) (9.0.4)
Requirement already satisfied: typing-extensions in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from playwright>=1.18->pytest-playwright) (4.7.1)
Collecting iniconfig (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting packaging (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting pluggy<2.0,>=0.12 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Obtaining dependency information for pluggy<2.0,>=0.12 from https://files.pythonhosted.org/packages/51/32/4a79112b8b87b21450b066e102d6608907f4c885ed7b04c3fdb085d4d6ae/pluggy-1.2.0-py3-none-any.whl.metadata
Using cached pluggy-1.2.0-py3-none-any.whl.metadata (4.4 kB)
Collecting exceptiongroup>=1.0.0rc8 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Obtaining dependency information for exceptiongroup>=1.0.0rc8 from https://files.pythonhosted.org/packages/fe/17/f43b7c9ccf399d72038042ee72785c305f6c6fdc6231942f8ab99d995742/exceptiongroup-1.1.2-py3-none-any.whl.metadata
Using cached exceptiongroup-1.1.2-py3-none-any.whl.metadata (6.1 kB)
Collecting tomli>=1.0.0 (from pytest<8.0.0,>=6.2.4->pytest-playwright)
Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting requests>=2.9 (from pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for requests>=2.9 from https://files.pythonhosted.org/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl.metadata
Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting text-unidecode>=1.3 (from python-slugify<9.0.0,>=6.0.0->pytest-playwright)
Using cached text_unidecode-1.3-py2.py3-none-any.whl (78 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in ./miniconda3/envs/crawl-playwright/lib/python3.8/site-packages (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright) (3.2.0)
Collecting idna<4,>=2.5 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for urllib3<3,>=1.21.1 from https://files.pythonhosted.org/packages/9b/81/62fd61001fa4b9d0df6e31d47ff49cfa9de4af03adecf339c7bc30656b37/urllib3-2.0.4-py3-none-any.whl.metadata
Using cached urllib3-2.0.4-py3-none-any.whl.metadata (6.6 kB)
Collecting certifi>=2017.4.17 (from requests>=2.9->pytest-base-url<3.0.0,>=1.0.0->pytest-playwright)
Obtaining dependency information for certifi>=2017.4.17 from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata
Using cached certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB)
Using cached pytest_playwright-0.4.2-py3-none-any.whl (10 kB)
Using cached pytest-7.4.0-py3-none-any.whl (323 kB)
Using cached exceptiongroup-1.1.2-py3-none-any.whl (14 kB)
Using cached pluggy-1.2.0-py3-none-any.whl (17 kB)
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
Downloading urllib3-2.0.4-py3-none-any.whl (123 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.9/123.9 kB 27.4 kB/s eta 0:00:00
Installing collected packages: text-unidecode, urllib3, tomli, python-slugify, pluggy, packaging, iniconfig, idna, exceptiongroup, certifi, requests, pytest, pytest-base-url, pytest-playwright
Successfully installed certifi-2023.7.22 exceptiongroup-1.1.2 idna-3.4 iniconfig-2.0.0 packaging-23.1 pluggy-1.2.0 pytest-7.4.0 pytest-base-url-2.0.0 pytest-playwright-0.4.2 python-slugify-8.0.1 requests-2.31.0 text-unidecode-1.3 tomli-2.0.1 urllib3-2.0.4
(crawl-playwright) mjl@ubuntu:~$ playwright install
Downloading Chromium 115.0.5790.75 (playwright build v1071) from https://playwright.azureedge.net/builds/chromium/1071/chromium-linux.zip
146.4 Mb [====================] 100% 0.0s
Chromium 115.0.5790.75 (playwright build v1071) downloaded to /home/mjl/.cache/ms-playwright/chromium-1071
Downloading FFMPEG playwright build v1009 from https://playwright.azureedge.net/builds/ffmpeg/1009/ffmpeg-linux.zip
2.6 Mb [====================] 100% 0.0s
FFMPEG playwright build v1009 downloaded to /home/mjl/.cache/ms-playwright/ffmpeg-1009
Downloading Firefox 115.0 (playwright build v1419) from https://playwright.azureedge.net/builds/firefox/1419/firefox-ubuntu-22.04.zip
79.1 Mb [====================] 100% 0.0s
Firefox 115.0 (playwright build v1419) downloaded to /home/mjl/.cache/ms-playwright/firefox-1419
Downloading Webkit 17.0 (playwright build v1869) from https://playwright.azureedge.net/builds/webkit/1869/webkit-ubuntu-22.04.zip
83.9 Mb [====================] 100% 0.0s
Webkit 17.0 (playwright build v1869) downloaded to /home/mjl/.cache/ms-playwright/webkit-1869
# Appid、Appkey、Secretkey、Signkey是您应用实际开发的主要凭证,每个应用唯一标示,互不相同,请妥善保管。

# AppID
# 37713175
# AppKey
# klm4OSRXDDY9vqnPpZXeimKHuMxpkzL0
# Secretkey
# gIKtwuwNBRtslfyrfHK0BSkwpPWSMXT0
# Signkey
# +HSPmm5C4OtEIx#!z%k6v@130TCr6x*z

python:自动化测试 playwright 库上传和下载

Dingding自定义机器人接入

Baidu网盘

Playwright for Python

http://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id=klm4OSRXDDY9vqnPpZXeimKHuMxpkzL0&redirect_uri=http://mjl2020.cn&scope=basic,netdisk&device_id=37713175
https://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&code=dced28cd7d2eb6efd84006ba14241996&client_id=klm4OSRXDDY9vqnPpZXeimKHuMxpkzL0&client_secret=gIKtwuwNBRtslfyrfHK0BSkwpPWSMXT0&redirect_uri=http://mjl2020.cn
{
"expires_in": 2592000,
"refresh_token": "122.7515444e412162ef597d416cbd47e1bb.YCyEY3XipV8gYIorg4HDZdphytJOp_TQ6Na_e8w.DovBQg",
"access_token": "121.e1833007022b7a01b213f0832716ecb9.YQt1PJsbSX55kb6sIG49vn62zWu8dxwoR3euLuS.hX0Trg",
"session_secret": "",
"session_key": "",
"scope": "basic netdisk"
}
(crawl-playwright) mjl@ubuntu:~/work/mjl2020/mjl2020/docs/code/pythonsdk_20220616$ conda install python-dateutil
Retrieving notices: ...working... done
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /home/mjl/miniconda3/envs/crawl-playwright

added / updated specs:
- python-dateutil


The following NEW packages will be INSTALLED:

python-dateutil anaconda/pkgs/main/noarch::python-dateutil-2.8.2-pyhd3eb1b0_0
six anaconda/pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_1


Proceed ([y]/n)? y


Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done