Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KauflandPriceSearchEngine

Hierarchy

Index

Constructors

Methods

  • collectLinks($: any, selector: string, attr: string, baseUrl?: string): string[]
  • collectOnAttributeAndElement($: CheerioAPI, selector: string, elementOrSelector: string, attribute: string, baseUrl?: string): any[]
  • Iterates through the selector and tries to find an element or a selector in the first given selector and returns the result as an array

    Parameters

    • $: CheerioAPI
    • selector: string
    • elementOrSelector: string
    • attribute: string
    • Optional baseUrl: string

    Returns any[]

    any[]

    Example:

    collectOnAttributeAndElement($, ".results--grid", "a", "href", baseUrl)
    // => will return an array containing all relative links in the href attribute that live in a
  • collectOnAttributeAndElementWithCallback($: CheerioAPI, selector: string, elementOrSelector: string, callback: (_: number, value: any) => void, baseUrl?: string): void
  • collectText($: CheerioAPI, selector: string): string[]
  • grabFirstPartAsNumber(value: string): any
  • onlyUnique(value: string, index: number, self: string | any[]): boolean
  • requestWebsite(baseUrl: string, fetchOptions?: IFetchOptions): Promise<CheerioAPI>
  • Fetches the website content and convert its content into text.

    Parameters

    Returns Promise<CheerioAPI>

    Promise<cheerio.CheerioAPI>

    Example:

    const $ = await requestWebsite("https://www.amazon.de/s?k=", "airpods")
    // => will return cheerio API Object to work with.

    $(".prices").each((_, value) => {
    console.log($(value).text().trim());
    });
  • spliceArray(array: string[], startPosition: number, endPosition: number): string[]
  • Splices an array content based on the given start and endpositions. Returns the original mutated array.

    Parameters

    • array: string[]
    • startPosition: number
    • endPosition: number

    Returns string[]

    string[]

    Example:

    const testArray = ["one", "two", "three"]
    spliceArray(testArray, 0, 2)
    // => ["three"]

    spliceArray(testArray, testArray.length - 2, 2)
    // => ["one"]
  • splitAndReplaceValue(array: string[], splitter: string, splitIndex: number, valueToReplace: string, replacement: string): number[]

Generated using TypeDoc