Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6908269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:32:29+00:00 2026-05-27T08:32:29+00:00

I have scraped a webpage using Scrapy and need to extract the background color

  • 0

I have scraped a webpage using Scrapy and need to extract the background color from certain objects. Because inline-css is not part of the DOM, or so I have read, I need to create a regex that will augment my current XPath and select the needed value within an object’s style attribute. My current XPath returns the entire style value like so:

background:#80FF00;height:48px;width:98px;color:#FFFFFF

I need a regex that will select the background hex value only (ie: #80FF00). I do not need to verify the value is properly formated (ie ([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}))\b ), just need to grab whatever is between ‘background:’ and the following ‘;’.

I am new to writing regular expressions and appreciate the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:32:30+00:00Added an answer on May 27, 2026 at 8:32 am

    The following regex should do what you want, the stuff you want to grab will be in the first capture group:

    background:(.*?);
    

    In Python

    background = re.search(r'background:(.*?);', some_string).group(1)
    

    . matches any character, * means repeat the previous element any number of times, and the ? makes it a lazy match, so it will match as few characters as possible. This is necessary to make sure that it doesn’t capture multiple semicolons and only stop at the last one. An alternative would be background:([^;]*) since [^;] would only match non-semicolon characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this situation where I need to get some data from a webpage
I am using CrawlSpider to crawl and extract data from a webpage. The start
I have used previous topics on how to scrape a webpage successfully using cURL
I am trying to scrape the datas from a webpage, but I get need
Here is the situation: I have a webpage that I have scraped as a
I have a text file which contains content scraped from webpages. The text file
The HTML you see below is text I have scraped from a remote site,
I have just scraped a bunch of Google Buzz data, and I want to
We are using a web scraper and have it set up to have a
I have a list of URLs from which I want to scrape an attribute.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.