Reputation: 2415
for getting background from this tag
<body style="background-image: url("http://www.auchandrive.fr/drive/static-media/public2/zones_edit/bannieres/_2016/S49/background_festif2016_boutique.jpg")
I use this code in Selenium
background = driver.find_element_by_css_selector('body').value_of_css_property('background-image')
how can i use this in Scrapy using Css Selector or Xpath?
Upvotes: 1
Views: 400
Reputation: 18799
In scrapy you can use CSS selectors directly:
You can get the node attribute with:
style = response.css('body::attr(style)').extract_first()
After this I am afraid scrapy doesn't offer something like value_of_css_property
directly, so you'll have to parse the attribute yourself:
value = response.css("body::attr(style)").re_first('background-image: (.*)$')
Upvotes: 1