Skip to content

Instantly share code, notes, and snippets.

@powerwlsl
Created July 12, 2023 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save powerwlsl/927d3c4b0ede16d909ca9f5412dc915e to your computer and use it in GitHub Desktop.
Save powerwlsl/927d3c4b0ede16d909ca9f5412dc915e to your computer and use it in GitHub Desktop.
var destinationGoogleSheetURL = 'https://docs.google.com/spreadsheets/d/1Y2-9AhJZY2hgHIdRcxFajOR-KA-0nGzXeQKJMkXTfEk/edit#gid=0';
var pageLimit = document.querySelector('#m_lblPagingSummary > b:nth-child(3)').innerText;
pageLimit = parseInt(pageLimit);
for (var i = 1; i <= pageLimit; i++) {
setTimeout(function () {
var listingAddress = document.querySelector(".d-mega.d-fontSize--larger.d-marginRight--20").innerText || 'unknown';
var listingLP = document.querySelector('.d-mega.d-fontWeight--bold.d-fontSize--larger.d-marginLeft--20').innerText || 'unknown';
var listingAgentName = document.querySelector('td.d94m49').innerText || 'unknown';
var listingAgentFirstName = listingAgentName.split(' ')[0]
var listingAgentLastName = listingAgentName.split(' ')[1]
var listingAgentPhone = document.querySelectorAll('table.d94m50 td.d94m52')[0].innerText || 'unknown';
var listingAgentMobile = document.querySelectorAll('table.d94m50 td.d94m52')[1] ? document.querySelectorAll('table.d94m50 td.d94m52')[1].innerText : '';
var listingAgentOffice = document.querySelectorAll('table.d94m50 td.d94m52')[2] ? document.querySelectorAll('table.d94m50 td.d94m52')[2].innerText : '';
var listingAgentEmail = document.querySelector('a[href^="mailto:"]').innerText || 'unknown';
var listingOfficeName = document.querySelectorAll('.d94m46')[1].querySelector('.formula.wrapped-field').innerText || 'unknown';
var listingDescriptionSection = Array.from(document.querySelectorAll('table.d57m2 .heading2.d57m24')).filter(header => header.innerText.includes("Public Remarks"))
var listingDescription = '';
if (listingDescriptionSection && listingDescriptionSection[0]) {
listingDescription = listingDescriptionSection[0].closest('tr').nextElementSibling.nextElementSibling.innerText || 'unknown';
}
google_sheets_add_row(
"1Y2-9AhJZY2hgHIdRcxFajOR-KA-0nGzXeQKJMkXTfEk",
/*name*/'Sheet7',
[
listingAddress,
listingLP,
listingAgentName,
listingAgentFirstName,
listingAgentLastName,
listingAgentPhone,
listingAgentMobile,
listingAgentOffice,
listingAgentEmail,
listingOfficeName,
listingDescription
]
);
var nextButton = document.querySelector('.pagingLinks a:nth-child(2)');
nextButton.click();
}, i * 3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment