回答くださったあと、代入文を入れたのですが、
url = driver.find_element_by_css_selector("div.event-preview__image").get_attribute("style")
url_image = url.replace("background-image: url(","")
url_image2 = url_image.replace(");","")
print(url_image2)
r_image = requests.get(url_image2)
リクエストメソッドを使うと
r_image = requests.get(url_image2)
"https:///sample.jpg"
Traceback (most recent call last):
File "c:/Users//Desktop/sa.py", line 19, in <module>
r_image = requests.get(url_image2)
File "C:\Users*****\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, kwargs)
File "C:\Users***\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, kwargs)
File "C:\Users***\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, send_kwargs)
File "C:\Users***\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 649, in send
adapter = self.get_adapter(url=request.url)
File "C:\Users*****\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 742, in get_adapter
raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for
'"https://*****/sample.jpg"'
“が関係しているのでしょうか。うまくreplaceされていない、最後に”/“が必要などご教示願います。