Skip to content

Commit

Permalink
Refactor exports
Browse files Browse the repository at this point in the history
  • Loading branch information
alexferrari88 committed Jun 10, 2022
1 parent d9b3efc commit bd6b2f2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ Install ScrapeBlocks with npm
#### Basic textContent strategy

```javascript
import { Scraper, TextContentScraping } from "scrapeblocks";
import { Scraper, ScrapingStragegies } from "scrapeblocks";

const URL = "https://webscraper.io/test-sites/e-commerce/allinone";
const selector = "h4.price";

const strategy = new TextContentScraping(selector);
const strategy = new ScrapingStragegies.TextContentScraping(selector);
const result = await new Scraper(URL, strategy).run();

console.log(result);
Expand All @@ -89,14 +89,14 @@ Output:
#### With actions

```javascript
import { Scraper, TextContentScraping, Select } from "scrapeblocks";
import { Scraper, ScrapingStragegies, Select } from "scrapeblocks";

const URL = "https://webscraper.io/test-sites/e-commerce/more/product/488";
const selectElement = "div.dropdown > select";
const optionToSelect = "Gold";
const selector = "div.caption > h4:nth-child(2)";

const strategy = new TextContentScraping(selector);
const strategy = new ScrapingStragegies.TextContentScraping(selector);
const selectAction = new Select({
element: selectElement,
value: optionToSelect,
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Action, ScrapingStrategy } from "./types";
import { USER_AGENTS } from "./utils/browser-config";

export class Scraper<T> {
class Scraper<T> {
browser: Browser | undefined;
context: BrowserContext | undefined;
page: Page | undefined;
Expand Down Expand Up @@ -68,3 +68,7 @@ export class Scraper<T> {
return result;
}
}

export * as ScrapingAction from "./scraping-actions";
export * as ScrapingStrategies from "./scraping-strategies";
export { Scraper };
16 changes: 7 additions & 9 deletions src/scraping-actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { AddCookies } from "./AddCookies";
import { Click } from "./Click";
import { Press } from "./Press";
import { Scroll } from "./Scroll";
import { Select } from "./Select";
import { Type } from "./Type";
import { Wait } from "./Wait";

export { AddCookies, Click, Press, Type, Scroll, Select, Wait };
export { AddCookies } from "./AddCookies";
export { Click } from "./Click";
export { Press } from "./Press";
export { Scroll } from "./Scroll";
export { Select } from "./Select";
export { Type } from "./Type";
export { Wait } from "./Wait";
1 change: 1 addition & 0 deletions src/scraping-strategies/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { TextContentScraping } from "./TextContentScraping";

0 comments on commit bd6b2f2

Please sign in to comment.