LinkedIn Profile URL Scrapper (from Google) avatar
LinkedIn Profile URL Scrapper (from Google)

Deprecated

Pricing

Pay per usage

Go to Store
LinkedIn Profile URL Scrapper (from Google)

LinkedIn Profile URL Scrapper (from Google)

Deprecated

Developed by

Rex Yagami

Rex Yagami

Maintained by Community

Scrape Data from Google search with use of Designation and Location.

0.0 (0)

Pricing

Pay per usage

7

Total users

307

Monthly users

3

Runs succeeded

>99%

Last modified

a year ago

.actor/Dockerfile

# Specify the base Docker image. You can read more about
# the available images at https://docs.apify.com/sdk/js/docs/guides/docker-images
# You can also use any other image from Docker Hub.
FROM apify/actor-node:20
# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
COPY package*.json ./
# Install NPM packages, skip optional and development dependencies to
# keep the image small. Avoid logging too much and print the dependency
# tree for debugging
RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version \
&& rm -r ~/.npm
# Next, copy the remaining files and directories with the source code.
# Since we do this after NPM install, quick build will be really fast
# for most source file changes.
COPY . ./
# Run the image.
CMD npm start --silent

.actor/actor.json

{
"actorSpecification": 1,
"name": "my-actor",
"title": "Project Cheerio Crawler Javascript",
"description": "Crawlee and Cheerio project in javascript.",
"version": "0.0",
"meta": {
"templateId": "js-crawlee-cheerio"
},
"input": "./input_schema.json",
"storages": {
"dataset": "./dataset_schema.json"
},
"dockerfile": "./Dockerfile"
}

.actor/dataset_schema.json

{
"actorSpecification": 1,
"fields": {
"LinkedIn URL": {
"type": "string",
"description": "The URL of the LinkedIn profile."
}
},
"views": {
"overview": {
"title": "Overview",
"transformation": {
"fields": ["LinkedIn URL"]
},
"display": {
"component": "table",
"properties": {
"LinkedIn URL": {
"label": "LinkedIn Profile URL",
"format": "link"
}
}
}
}
}
}

.actor/input_schema.json

{
"title": "Scrape LinkedIn profiles based on keywords",
"type": "object",
"schemaVersion": 1,
"properties": {
"keywords": {
"title": "Search Keywords",
"type": "array",
"description": "Enter the keywords to search for LinkedIn profiles, e.g., job titles, and locations.",
"editor": "stringList",
"items": {
"type": "string"
},
"prefill": ["chief product officer", "united states"]
},
"numPages": {
"title": "Number of Pages",
"type": "integer",
"description": "The number of pages to scrape (each page corresponds to a set of search results).",
"editor": "number",
"minimum": 1,
"default": 1
}
},
"required": ["keywords", "numPages"]
}

.actor/output_schema.json

{
"title": "LinkedIn Profile URLs",
"type": "array",
"items": {
"type": "object",
"properties": {
"LinkedIn URL": {
"type": "string",
"description": "The URL of the LinkedIn profile."
}
},
"required": ["LinkedIn URL"]
}
}

src/main.js

1import { Actor, log } from 'apify';
2import { CheerioCrawler } from 'crawlee';
3
4await Actor.init();
5
6try {
7 const input = await Actor.getInput();
8 const keywords = input.keywords ? input.keywords.slice(0, 2) : ["chief product officer", "united states"];
9 const numPages = input.numPages || 1;
10
11 const baseUrl = 'https://www.google.com/search?q=site%3Alinkedin.com%2Fin%2F+';
12 const formattedKeywords = keywords.map(keyword => `%22${keyword.replace(/ /g, "+")}%22`).join('+');
13 const headers = {
14 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
15 };
16
17 const linkedinUrlsSet = new Set();
18
19 // Generate URLs for the number of pages specified
20 const urls = [];
21 for (let page = 0; page < numPages; page++) {
22 const start = page * 10;
23 urls.push(`${baseUrl}${formattedKeywords}&start=${start}`);
24 }
25
26 const requestQueue = await Actor.openRequestQueue();
27 for (const url of urls) {
28 await requestQueue.addRequest({ url, headers });
29 }
30
31 const crawler = new CheerioCrawler({
32 requestQueue,
33 requestHandler: async ({ request, $ }) => {
34 console.log(`Processing ${request.url}...`);
35
36 $('a').each((index, element) => {
37 const href = $(element).attr('href');
38 const match = href && href.match(/(https?:\/\/www\.linkedin\.com\/in\/[^&]+)/);
39 if (match) {
40 const linkedinUrl = match[1];
41 linkedinUrlsSet.add(linkedinUrl); // Add to set to ensure uniqueness
42 }
43 });
44 },
45 });
46
47 await crawler.run();
48
49 // Convert set to array for pushing to dataset
50 const linkedinUrlsArray = Array.from(linkedinUrlsSet);
51
52 // Push unique results to dataset
53 const results = linkedinUrlsArray.map(url => ({ "LinkedIn URL": url }));
54 await Actor.pushData(results);
55
56 log.info(`Found and saved ${linkedinUrlsSet.size} unique LinkedIn URLs based on the keywords across ${numPages} pages.`);
57} catch (error) {
58 console.error('Error during actor run:', error);
59 throw error;
60}
61
62await Actor.exit();

.dockerignore

# configurations
.idea
# crawlee and apify storage folders
apify_storage
crawlee_storage
storage
# installed files
node_modules
# git folder
.git

.editorconfig

root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

.eslintrc

{
"extends": "@apify",
"root": true
}

.gitignore

# This file tells Git which files shouldn't be added to source control
.DS_Store
.idea
dist
node_modules
apify_storage
storage

package.json

{
"name": "crawlee-cheerio-javascript",
"version": "0.0.1",
"type": "module",
"description": "This is a boilerplate of an Apify actor.",
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"apify": "^3.1.10",
"crawlee": "^3.5.4",
"googleapis": "^118.0.0"
},
"devDependencies": {
"@apify/eslint-config": "^0.4.0",
"eslint": "^8.50.0"
},
"scripts": {
"start": "node src/main.js",
"lint": "eslint ./src --ext .js,.jsx",
"lint:fix": "eslint ./src --ext .js,.jsx --fix",
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
},
"author": "It's not you it's me",
"license": "ISC"
}