{ "info": { "author": "Yihang Wang", "author_email": "wangyihanger@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12" ], "description": "# Python requests.HTTPAdapter for `acw_sc__v2`\n\n`acw_sc__v2` is a cookie used by some websites to prevent crawlers.\nWhen the website detects that the request is sent by a crawler, it returns a javascript challenge. The crawler needs to solve the challenge and resend the request with the cookie set to the challenge value.\nThis project provides a Python requests.HTTPAdapter to resolve the challenge automatically.\n\n## Usage\n\n```bash\npip install acw-sc-v2-py\n```\n\n```python\nimport requests\n\nsession = requests.Session()\n\n# add the following code to your original requests code\nfrom acw_sc_v2_py import acw_sc__v2 \nadapter = acw_sc__v2.AcwScV2Adapter()\nsession.mont(\"http://\", adapter)\nsession.mount(\"https://\", adapter)\n\nresponse = session.get(\"https://www.example.com/\")\nprint(response.text)\n```\n\n## Use Case\n\n### Before using `acw-sc-v2-py`\n\n``` python\nimport requests\n\nsession = requests.Session()\n\nfor i in range(8):\n response = session.get(\"https://www.example.com/\")\n print(response.text)\n```\n\nUsually, you will get blocked after sending 2 consecutive requests to\nthe same website. The response will be like the following HTML code\nwhich requires you to solve a javascript challenge. If the web page is\nopened in a browser, the browser will automatically solve the challenge.\n\n``` html\n\n```\n\n### After using `acw-sc-v2-py`\n\n``` python\nimport requests\n# step 1: import\nfrom acw_sc_v2_py import acw_sc__v2 \n\nsession = requests.Session()\n\n# step 2: create adapter\nadapter = acw_sc__v2.AcwScV2Adapter()\n\n# step 3: mount adapter\nsession.mont(\"http://\", adapter)\nsession.mount(\"https://\", adapter)\n\nfor i in range(8):\n response = session.get(\"https://www.example.com/\")\n print(response.text)\n```\n\nBy using `acw-sc-v2-py`, you will get the normal response. The\n`acw_sc__v2` will handle the javascript challenge and automatically\nupdate the cookie.\n\n### Enable logging\n\nPrepend the following code to enable detailed log for `acw-sc-v2-py`.\n\n``` python\nimport logging\nlogger = logging.getLogger(\"acw_sc_v2_py.acw_sc__v2\")\nlogger.setLevel(logging.DEBUG)\nlogger.propagate = True\n\nimport requests\nfrom acw_sc_v2_py import acw_sc__v2 \n\nsession = requests.Session()\n\nadapter = acw_sc__v2.AcwScV2Adapter()\nsession.mont(\"http://\", adapter)\nsession.mount(\"https://\", adapter)\n\nfor i in range(8):\n response = session.get(\"https://www.example.com/\")\n print(response.text)\n```\n\nThe log will be like the following.\n\n``` plain\n[2024-01-26 22:01:26] INFO:root:detected anti spam is triggered\n[2024-01-26 22:01:28] INFO:root:cookie generated acw_sc__v2=65b3bb3601fe9ab002c5c1ff58fc71a1115e8322\n[2024-01-26 22:01:28] INFO:root:resending the origin request\n\n[2024-01-26 22:01:29] INFO:root:cookie set acw_sc__v2=65b3bb3601fe9ab002c5c1ff58fc71a1115e8322\n[2024-01-26 22:01:30] INFO:root:anti spam is not triggered\n\n...\n```\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "acw-sc-v2-py", "package_url": "https://pypi.org/project/acw-sc-v2-py/", "platform": null, "project_url": "https://pypi.org/project/acw-sc-v2-py/", "project_urls": null, "release_url": "https://pypi.org/project/acw-sc-v2-py/0.0.5/", "requires_dist": [ "requests (>=2.31.0,<3.0.0)" ], "requires_python": ">=3.10,<4.0", "summary": "", "version": "0.0.5", "yanked": false, "yanked_reason": null }, "last_serial": 21602583, "releases": { "0.0.5": [ { "comment_text": "", "digests": { "blake2b_256": "daf151c357d68931b4ae8f6e037b9a649c20a282db7bd4d38528d0b724432288", "md5": "fb6c62bda95f4c5b19c6c304780e45a3", "sha256": "aa7a315a4e4f0d29c2a05f80c57dc2b35b16d6ee1b8a32a27dc3966069b6ee17" }, "downloads": -1, "filename": "acw_sc_v2_py-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "fb6c62bda95f4c5b19c6c304780e45a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.10,<4.0", "size": 3614, "upload_time": "2024-01-26T15:02:21", "upload_time_iso_8601": "2024-01-26T15:02:21.299930Z", "url": "https://files.pythonhosted.org/packages/da/f1/51c357d68931b4ae8f6e037b9a649c20a282db7bd4d38528d0b724432288/acw_sc_v2_py-0.0.5-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "blake2b_256": "6f762abd04bf0928466bc112e7718308e9d5dc19a4eaedfa6549591ecb459edc", "md5": "4af06d79dad17b4e6d67359a062375ed", "sha256": "472e0e97f01ca15e1b00fcb568084f3ec9137bac83996ffbd42339338181a54a" }, "downloads": -1, "filename": "acw_sc_v2_py-0.0.5.tar.gz", "has_sig": false, "md5_digest": "4af06d79dad17b4e6d67359a062375ed", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.10,<4.0", "size": 2963, "upload_time": "2024-01-26T15:02:23", "upload_time_iso_8601": "2024-01-26T15:02:23.294735Z", "url": "https://files.pythonhosted.org/packages/6f/76/2abd04bf0928466bc112e7718308e9d5dc19a4eaedfa6549591ecb459edc/acw_sc_v2_py-0.0.5.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "blake2b_256": "daf151c357d68931b4ae8f6e037b9a649c20a282db7bd4d38528d0b724432288", "md5": "fb6c62bda95f4c5b19c6c304780e45a3", "sha256": "aa7a315a4e4f0d29c2a05f80c57dc2b35b16d6ee1b8a32a27dc3966069b6ee17" }, "downloads": -1, "filename": "acw_sc_v2_py-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "fb6c62bda95f4c5b19c6c304780e45a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.10,<4.0", "size": 3614, "upload_time": "2024-01-26T15:02:21", "upload_time_iso_8601": "2024-01-26T15:02:21.299930Z", "url": "https://files.pythonhosted.org/packages/da/f1/51c357d68931b4ae8f6e037b9a649c20a282db7bd4d38528d0b724432288/acw_sc_v2_py-0.0.5-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "blake2b_256": "6f762abd04bf0928466bc112e7718308e9d5dc19a4eaedfa6549591ecb459edc", "md5": "4af06d79dad17b4e6d67359a062375ed", "sha256": "472e0e97f01ca15e1b00fcb568084f3ec9137bac83996ffbd42339338181a54a" }, "downloads": -1, "filename": "acw_sc_v2_py-0.0.5.tar.gz", "has_sig": false, "md5_digest": "4af06d79dad17b4e6d67359a062375ed", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.10,<4.0", "size": 2963, "upload_time": "2024-01-26T15:02:23", "upload_time_iso_8601": "2024-01-26T15:02:23.294735Z", "url": "https://files.pythonhosted.org/packages/6f/76/2abd04bf0928466bc112e7718308e9d5dc19a4eaedfa6549591ecb459edc/acw_sc_v2_py-0.0.5.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }