gazpacho
gazpacho copied to clipboard
AttributeError: 'Soup' object has no attribute 'decode'
I tried code:
all_urls = [link.attrs['href'] for link in Soup(get(browser_link)).find('a')]
and I got AttributeError: 'Soup' object has no attribute 'decode'. What check? Where is mistake in my code?
Full info:
File "C:\webscraper\lib\site-packages\gazpacho\get.py", line 29, in get
url = sanitize(url)
File "C:\webscraper\lib\site-packages\gazpacho\utils.py", line 128, in sanitize
scheme, netloc, path, query, fragment = urlsplit(url)
File "C:\Program Files\Python39\lib\urllib\parse.py", line 455, in urlsplit
url, scheme, _coerce_result = _coerce_args(url, scheme)
File "C:\Program Files\Python39\lib\urllib\parse.py", line 125, in _coerce_args
return _decode_args(args) + (_encode_result,)
File "C:\Program Files\Python39\lib\urllib\parse.py", line 109, in _decode_args
return tuple(x.decode(encoding, errors) if x else '' for x in args)
File "C:\Program Files\Python39\lib\urllib\parse.py", line 109, in <genexpr>
return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'Soup' object has no attribute 'decode'
Seems it’s failing on get
...
I would replace get with requests.get, and then use Soup() on the resulting html.
I tried in production and your recommendation is the best one. Problem was solved this way. Thank you