# inscraper

> A playwright based scraper for linked in profiles (for now)

Latest version **1.2.8** (published 2023-01-29) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install inscraper
pnpm add inscraper
yarn add inscraper
bun add inscraper
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.8 |
| Published | 2023-01-29 |
| First published | 2023-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 45.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | David Garay |
| Maintainers | garaekz |
| Keywords | inscraper, linkedin, scraper, playwright, scraping, linkedin-scraper, linkedin-scrapper, linkedin-scrapping, linkedin-scrapping, linkedin-scraper, linkedin-scrapper, linkedin-scrapping, linkedin-scrapping |

## Links

- npm: https://www.npmjs.com/package/inscraper
- Repository: https://github.com/garaekz/inscraper
- Homepage: https://github.com/garaekz/inscraper#readme
- Issues: https://github.com/garaekz/inscraper/issues
- npm.io page: https://npm.io/package/inscraper

## Dependencies (3)

- [nodemon](https://npm.io/package/nodemon.md) ^2.0.20
- [playwright](https://npm.io/package/playwright.md) ^1.30.0
- [@types/node](https://npm.io/package/@types/node.md) ^18.11.18

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.2.8 (latest) — 2023-01-29
- 1.2.1 — 2023-01-29
- 1.2.0 — 2023-01-29
- 1.1.0 — 2023-01-28
- 1.0.6 — 2023-01-28
- 1.0.5 — 2023-01-26
- 1.0.4 — 2023-01-26
- 1.0.3 — 2023-01-26
- 1.0.2 — 2023-01-26
- 1.0.1 — 2023-01-26
- 1.0.0 — 2023-01-26

## README

# InScraper
### A playwright based LinkedIn based scraper

This is (currently) a small library built in typescript in order to scrape LinkedIn profiles using the vanity URL (slug or custom URL) using Playwright ~~and Cheerio~~.

I'm trying to stick to semver but I'm not sure if I'm doing it right, so please be aware that this library is still in development and the API may change.

## Why?
I was looking for a way to get some information from LinkedIn profiles and I found that there are some libraries that do that, but they are not maintained anymore and they use Puppeteer, which is a bit slow and heavy. I wanted to try Playwright, which is a new library that is built on top of Chromium, Firefox and Webkit, so it's faster and lighter than Puppeteer. I also wanted to try to use TypeScript, so I decided to build this library. I hope you find it useful.

## Disclaimer
This library is provided as is, without any warranty. I am not responsible for any misuse of this library. Please be aware that web scraping may be against the terms of service of LinkedIn, try to use a side account because it may get you banned (haven't see that yet but could be).

## Installation

    npm install inscraper
Using Yarn:

     yarn add inscraper

## Usage
 To use the library, you will need to provide a valid LinkedIn cookie. You can obtain this by logging into LinkedIn and inspecting the cookies in your browser, search for the one called `li_at`. Once you have the cookie, you can pass it to the `createClient` function, which will return an instance of the `Client` class.

    import { createClient } from  'inscraper';
   
    const cookieString = 'YOUR_COOKIE_HERE';
    const client = await  createClient(cookieString);

 The `Client` class has the following methods:

-   `getProfile(slug: string)`: Returns the profile information of the user with the given profile slug, including their name, headline, about and experience sections.
    
-   `getExperience(slug: string)`: Returns only the experience of the user with the given profile slug.

-   `getScreenshot()`: You can use this method to get a screenshot of the current page. This is useful if you want to see what the page looks like after you have performed some actions. It only works if you have called the `getProfile` or `getExperience` methods before. It's built on top of Playwright's `screenshot` method, so you can pass the same options to it. See [Playwright's documentation](https://playwright.dev/docs/api/class-page#page-screenshot) for more information.


Get some profile info:

```
const profile = await client.getProfile('profile-slug');
console.log(profile);

const experience = await client.getExperience('profile-slug);
console.log(experience);
```

Note that if the provided cookie is invalid, the library will throw an error, 'Cookies error'

## Full Example
```
import fs from "fs";
import { PageScreenshotOptions } from 'playwright';
import { createClient } from "inscraper/client";

const cookieString = 'YOUR_COOKIE_HERE';
const client = await createClient(cookieString);

const slug = 'profile-slug';

const profile = await client.getProfile(slug);
console.log(profile);
const options: PageScreenshotOptions = {
  type: "png",
  fullPage: true,
}
const buffer = await profile.getScreenshot(options)
fs.writeFileSync(`screenshots/${slug}.png`, buffer);

const experience = await client.getExperience(slug);
console.log(experience);
await client.close()
```
## Compatibility 
This library uses Playwright, which is compatible with Chromium, Firefox and Webkit. For this implementation, Chromium is being used.

## Dependencies
This library depends on playwright ~~and cheerio~~.

## Contributions
Your contributions are always welcome! Please feel free to submit a pull request or open an issue.

## Features
- [x] Work with Cookies
- [x] Get basic info from Profile
- [x] Get Experience from Profile
- [ ] Get Education from Profile
- [ ] Get Skills from Profile
- [ ] Get Recommendations from Profile
- [x] Get Screenshots of a visited profile
- [ ] Extend it to try and use voyager API (see if that's still a thing)
- [ ] Add a test suite
- [ ] Add more features to this list
- [ ] Check if people like this and work on people recommendations 😅

## License
This library is provided under the [MIT License](https://opensource.org/licenses/MIT).

## Contact 
Please feel free to contact me if you have any questions or issues.

---
_Source: https://npm.io/package/inscraper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
