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 `SupportsIndex` in Python 3.6 and 3.7

Karim shoair84b0ea6121f8
diff --git a/scrapling/parser.py b/scrapling/parser.py
index c0cc7be..375d384 100644
--- a/scrapling/parser.py
+++ b/scrapling/parser.py
@@ -1,6 +1,11 @@
import os
from difflib import SequenceMatcher
-from typing import Any, Dict, List, Tuple, Optional, Pattern, SupportsIndex, Union, Callable, Generator
+from typing import Any, Dict, List, Tuple, Optional, Pattern, Union, Callable, Generator
+try:
+ from typing import SupportsIndex
+except ImportError:
+ # 'SupportsIndex' got added in Python 3.8
+ SupportsIndex = None
from scrapling.translator import HTMLTranslator
from scrapling.mixins import SelectorsGeneration