From 5f9c3980dc5c28062f3240e547841d99e0eb7674 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Tue, 10 Dec 2024 22:02:43 +0200 Subject: [PATCH] Adding `urljoin` method to Adaptors and Responses --- scrapling/parser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scrapling/parser.py b/scrapling/parser.py index 169c9e7..85fd79e 100644 --- a/scrapling/parser.py +++ b/scrapling/parser.py @@ -2,6 +2,7 @@ import inspect import os import re from difflib import SequenceMatcher +from urllib.parse import urljoin from cssselect import SelectorError, SelectorSyntaxError from cssselect import parse as split_selectors @@ -243,6 +244,10 @@ class Adaptor(SelectorsGeneration): return TextHandler(separator.join([s for s in _all_strings])) + def urljoin(self, relative_url: str) -> str: + """Join this Adaptor's url with a relative url to form an absolute full URL.""" + return urljoin(self.url, relative_url) + @property def attrib(self) -> AttributesHandler: """Get attributes of the element"""