` with the class `"title-type-sup-property"`.
The challenge here is that this text contains **more than just the number.** It includes extra words and symbols, meaning we can’t simply extract the full content. Instead, we need to **isolate just the numeric value before "m²"**.
This is where **regular expressions (`re`)** come in. Instead of extracting everything, we’ll use a pattern that looks for:
* **A number (`\d+`)**
* **That appears right before "m²"**
This allows us to grab the exact value we need without any extra text.
```python
<----- Previous section until the Print command ----->
# Extract square meters from title-type-sup-property
title_content = soup.find("h2", class_="title-type-sup-property").text.strip()
square_meters = re.search(r"(\d+)\s*m²", title_content).group(1)
print("Listing Name:", listing_name)
print("Square Meters:", square_meters)
```
With this, we’ve **filtered out unnecessary words** and **kept only the number before "m²" so it looks clean**.
The output should look like this:
```yaml
Listing Name: Casa no Condominio East Village disponível para venda
Square Meters: 1200
```
### Extracting the Sale Price
The price is inside a `
` tag with the class `"price-value"`, but it sometimes contains extra words like `"venda"`, which we don’t need.
Instead of extracting everything, we'll make use of **regular expressions (`re`)** again to grab only the **currency symbol (`R$`) followed by numbers**, ensuring we capture the price **without unnecessary text**.
After adding the price extraction code, here's what the final code should look like:
```python
from bs4 import BeautifulSoup
import requests
import urllib.parse
import re
# Our token provided by Scrape.do
token = ""
# Target Imovelweb listing URL
target_url = urllib.parse.quote_plus("https://www.imovelweb.com.br/propriedades/casa-no-condominio-east-village-disponivel-para-venda-2986272608.html")
# Optional parameters
render = "true"
geo_code = "br"
# Scrape.do API endpoint
url = f"https://api.scrape.do/?token={token}&url={target_url}&geoCode={geo_code}&render={render}"
# Send the request
response = requests.request("GET", url)
# Parse the response using BeautifulSoup
soup = BeautifulSoup(response.text, "html.parser")
# Extract listing name
listing_name = soup.find("h1").text.strip()
# Extract square meters from title-type-sup-property
title_content = soup.find("h2", class_="title-type-sup-property").text.strip()
square_meters = re.search(r"(\d+)\s*m²", title_content).group(1)
# Extract sale price and remove unwanted words
price_text = " ".join(soup.find("div", class_="price-value").stripped_strings)
price = re.search(r"R\$\s*[\d.,]+", price_text).group(0)
print("Listing Name:", listing_name)
print("Square Meters:", square_meters)
print("Sale Price:", price)
```
And the output should look like this:
```yaml
Listing Name: Casa no Condominio East Village disponível para venda
Square Meters: 1200
Sale Price: R$ 16.000.000
```
That’s it. You've successfully scraped Imovelweb!
## Conclusion
Scraping Imovelweb comes with challenges like **DataDome protection and regional access controls**, but with **Scrape.do**, these obstacles are bypassed automatically.
We successfully extracted the **property name, square meters, and sale price** without getting blocked by using **geo-targeted IPs, session management, and JavaScript rendering**.
Need to scrape Imovelweb?
**Scrape.do makes it effortless.**
[Get **1000 free API calls** and start now.](https://scrape.do) 🚀