As part of my project to create a custom Google Chrome extension, I encountered an interesting challenge. When I perform a GET request on the following web page URL:
https://www.rightmove.co.uk/property-for-sale/find.html?locationIdentifier=REGION%5E27675&maxBedrooms=2&minBedrooms=2&sortType=6&propertyTypes=&mustHave=&dontShow=&furnishTypes=&keywords=
, I receive the HTML response from the webpage as expected. The website I am accessing does not provide an API, and web scraping is not an option due to certain constraints.
The issue arises when I try to split the string I received at a specific point, namely bis_skin_checked
. Surprisingly, despite this term being present in the string, the split operation returns an array with only one element, indicating that no match was found. I have attempted various methods such as eliminating spaces and line breaks, but none have proved successful so far. Below is the code snippet for my GET request:
function getNewPage(url) {
let returnedValue = fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'text/html',
},
})
.then(response => response.text())
.then(text => {
return text
})
return returnedValue
}
Following this, I move on to resolve the promise associated with returnedValue
:
let newURL = getHousePrices(currentUrl) // Obtain Promise object representing the new page content
newURL.then(function(value) { // Resolve the promise and perform desired actions
console.log(value.split('bis_skin_checked').length)
})
I then proceed to manipulate the retrieved string, which resembles the data shown in the image accessed via the following link (as direct text extraction is not feasible):