Karim shoair commited on
Commit
deb22eb
·
1 Parent(s): ef19167

Adding `urljoin` method to Adaptors and Responses

Browse files
Files changed (1) hide show
  1. scrapling/parser.py +5 -0
scrapling/parser.py CHANGED
@@ -2,6 +2,7 @@ import inspect
2
  import os
3
  import re
4
  from difflib import SequenceMatcher
 
5
 
6
  from cssselect import SelectorError, SelectorSyntaxError
7
  from cssselect import parse as split_selectors
@@ -243,6 +244,10 @@ class Adaptor(SelectorsGeneration):
243
 
244
  return TextHandler(separator.join([s for s in _all_strings]))
245
 
 
 
 
 
246
  @property
247
  def attrib(self) -> AttributesHandler:
248
  """Get attributes of the element"""
 
2
  import os
3
  import re
4
  from difflib import SequenceMatcher
5
+ from urllib.parse import urljoin
6
 
7
  from cssselect import SelectorError, SelectorSyntaxError
8
  from cssselect import parse as split_selectors
 
244
 
245
  return TextHandler(separator.join([s for s in _all_strings]))
246
 
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
+
251
  @property
252
  def attrib(self) -> AttributesHandler:
253
  """Get attributes of the element"""