Merge branch 'dev' into fix/quoted-charset-encoding
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
__author__ = "Karim Shoair (karim.shoair@pm.me)"
|
||||
__version__ = "0.4.8"
|
||||
__version__ = "0.4.9"
|
||||
__copyright__ = "Copyright (c) 2024 Karim Shoair"
|
||||
|
||||
from typing import Any, TYPE_CHECKING
|
||||
|
||||
+3
-1
@@ -2,6 +2,7 @@ from pathlib import Path
|
||||
from subprocess import check_output
|
||||
from sys import executable as python_executable
|
||||
|
||||
from scrapling import __version__
|
||||
from scrapling.core.utils import log
|
||||
from scrapling.engines.toolbelt.custom import Response
|
||||
from scrapling.core.utils._shell import _CookieParser, _ParseHeaders
|
||||
@@ -10,7 +11,7 @@ from scrapling.core._types import List, Optional, Dict, Tuple, Any, Callable
|
||||
from orjson import loads as json_loads, JSONDecodeError
|
||||
|
||||
try:
|
||||
from click import command, option, Choice, group, argument
|
||||
from click import command, option, Choice, group, argument, version_option
|
||||
except (ImportError, ModuleNotFoundError) as e:
|
||||
raise ModuleNotFoundError(
|
||||
"You need to install scrapling with any of the extras to enable Shell commands. See: https://scrapling.readthedocs.io/en/latest/#installation"
|
||||
@@ -650,6 +651,7 @@ def stealthy_fetch(
|
||||
|
||||
|
||||
@group()
|
||||
@version_option(version=__version__, prog_name="Scrapling")
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ from scrapling.core._types import Dict, Literal, Tuple
|
||||
__OS_NAME__ = platform_system()
|
||||
OSName = Literal["linux", "macos", "windows"]
|
||||
# Current versions hardcoded for now (Playwright doesn't allow to know the version of a browser without launching it)
|
||||
chromium_version = 147
|
||||
chrome_version = 147
|
||||
chromium_version = 148
|
||||
chrome_version = 148
|
||||
|
||||
|
||||
@lru_cache(1, typed=True)
|
||||
|
||||
+4
-2
@@ -671,7 +671,7 @@ class Selector(SelectorsGeneration):
|
||||
element_data = self.retrieve(identifier or selector)
|
||||
if element_data:
|
||||
elements = self.relocate(element_data, percentage)
|
||||
if elements is not None and auto_save:
|
||||
if elements and auto_save:
|
||||
self.save(elements[0], identifier or selector)
|
||||
|
||||
return self.__handle_elements(elements)
|
||||
@@ -991,7 +991,9 @@ class Selector(SelectorsGeneration):
|
||||
SequenceMatcher(None, v, candidate_attributes.get(k, "")).ratio()
|
||||
for k, v in original_attributes.items()
|
||||
)
|
||||
checks += len(candidate_attributes)
|
||||
# Using `max` so candidates with extra attributes are penalized and candidates
|
||||
# with fewer attributes don't get inflated scores from a smaller denominator
|
||||
checks += max(len(original_attributes), len(candidate_attributes))
|
||||
else:
|
||||
if not candidate_attributes:
|
||||
# Both don't have attributes, this must mean something
|
||||
|
||||
@@ -64,7 +64,7 @@ class ResponseCacheManager:
|
||||
async with await anyio.open_file(temp_path, "wb") as f:
|
||||
await f.write(serialized)
|
||||
|
||||
await temp_path.rename(self._cache_path(fingerprint))
|
||||
await temp_path.replace(self._cache_path(fingerprint))
|
||||
except Exception as e:
|
||||
if await temp_path.exists():
|
||||
await temp_path.unlink()
|
||||
|
||||
@@ -50,7 +50,7 @@ class CheckpointManager:
|
||||
async with await anyio.open_file(temp_path, "wb") as f:
|
||||
await f.write(serialized)
|
||||
|
||||
await temp_path.rename(self._checkpoint_path)
|
||||
await temp_path.replace(self._checkpoint_path)
|
||||
|
||||
log.info(f"Checkpoint saved: {len(data.requests)} requests, {len(data.seen)} seen URLs")
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user