Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

Handle importing `Protocol` in Python 3.6 and 3.7

Karim shoairc85fabb581f5
diff --git a/scrapling/translator.py b/scrapling/translator.py
index 94e61ca..ec6db86 100644
--- a/scrapling/translator.py
+++ b/scrapling/translator.py
@@ -9,7 +9,12 @@ which will be important in future releases but most importantly...
import re
from w3lib.html import HTML5_WHITESPACE
-from typing import TYPE_CHECKING, Any, Optional, Protocol
+from typing import TYPE_CHECKING, Any, Optional
+try:
+ from typing import Protocol
+except ImportError:
+ # Added in Python 3.8
+ Protocol = object
from scrapling.utils import cache