Skip to content

Commit 5f9c398

Browse files
committed
Adding urljoin method to Adaptors and Responses
1 parent d0f1895 commit 5f9c398

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scrapling/parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import re
44
from difflib import SequenceMatcher
5+
from urllib.parse import urljoin
56

67
from cssselect import SelectorError, SelectorSyntaxError
78
from cssselect import parse as split_selectors
@@ -243,6 +244,10 @@ def _traverse(node: html.HtmlElement) -> None:
243244

244245
return TextHandler(separator.join([s for s in _all_strings]))
245246

247+
def urljoin(self, relative_url: str) -> str:
248+
"""Join this Adaptor's url with a relative url to form an absolute full URL."""
249+
return urljoin(self.url, relative_url)
250+
246251
@property
247252
def attrib(self) -> AttributesHandler:
248253
"""Get attributes of the element"""

0 commit comments

Comments
 (0)