Step 1: Create a New Google Sheet
Open Google Sheets.
Click on Blank Spreadsheet.
In the first row, create the following column headers:
A1: URL
B1: Emails
C1: Phones
D1: Status
Step 2: Open Apps Script
From the top menu, click on Extensions.
Click on Apps Script.
👉 (Add screenshot of Extensions → Apps Script here)
A new tab will open with the Google Apps Script Editor.
Step 3: Paste the Scraping Code
In the Apps Script editor, remove any default code.
Paste the following code:
function extractWebsiteDataBatch() {
const sheet = SpreadsheetApp.getActiveSheet();
const lastRow = sheet.getLastRow();
let startRow = PropertiesService.getScriptProperties().getProperty("startRow");
startRow = startRow ? parseInt(startRow) : 2;
const batchSize = 500; // PROCESS 500 URLs PER RUN
const endRow = Math.min(startRow + batchSize - 1, lastRow);
for (let i = startRow; i <= endRow; i++) {
let url = sheet.getRange(i, 1).getValue();
if (!url) continue;
try {
let response = UrlFetchApp.fetch(url, {
muteHttpExceptions: true,
followRedirects: true
});
let content = response.getContentText();
// Extract emails
let emails = content.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}/g);
emails = emails ? [...new Set(emails)] : [];
// Extract ONLY phone numbers starting with +
let phones = content.match(/\+\d[\d\s\-()]{6,20}/g);
phones = phones ? [...new Set(phones.map(p => p.replace(/[^\d+]/g, "")))] : [];
sheet.getRange(i, 2).setValue(emails.join(", "));
sheet.getRange(i, 3).setValue(phones.join(", "));
} catch (err) {
sheet.getRange(i, 2).setValue("Error");
sheet.getRange(i, 3).setValue("Error");
}
}
// Save next range
if (endRow < lastRow) {
PropertiesService.getScriptProperties().setProperty("startRow", endRow + 1);
// Auto-run next batch after 5 seconds
ScriptApp.newTrigger("extractWebsiteDataBatch")
.timeBased()
.after(5000)
.create();
} else {
PropertiesService.getScriptProperties().deleteProperty("startRow");
SpreadsheetApp.getUi().alert("All scraping completed!");
}
}
Step 4: Save the Project
Click on Save Project.
Give your project a name (example:
Bulk Data Scraper).Click Save.
Step 5: Run the Script (First Time Authorization)
Click the Run button.
Google will ask for Authorization.
Select your Gmail account.
Click Advanced → Go to Project (if warning appears).
Click Allow.
After permission is granted, the script becomes active.
Step 6: Add Bulk URLs in the Sheet
Go back to your Google Sheet.
Add your website URLs in Column A (URL) starting from Row 2.
You can paste bulk URLs (hundreds or thousands).
Step 7: Run the Scraper
Click again on Extensions.
Open Apps Script.
Click Run.
The script will now:
Visit each website
Extract emails
Extract phone numbers (only starting with +)
Fill data in:
Column B → Emails
Column C → Phones
It processes 500 URLs per run automatically and continues in batches every 5 seconds until all URLs are completed.
Final Result
Emails will appear in Column B
Phone numbers in Column C
When all URLs are processed, you will see a popup message:
"All scraping completed!"
.png)

1 Comments
Gr8 sir
ReplyDelete