How to use the random-http-useragent.get function in random-http-useragent

To help you get started, we’ve selected a few random-http-useragent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hfreire / browser-as-a-service / src / browser.js View on Github external
async open (url) {
    if (!url) {
      throw new Error('invalid arguments')
    }

    const result = {}

    const userAgent = await RandomHttpUserAgent.get()

    const browser = await puppeteer.launch(_.get(this._options, 'puppeteer'))

    const page = await browser.newPage()
    await page.setUserAgent(userAgent)

    page.on('console', (consoleMessage) => {
      if (!result.console) {
        result.console = []
      }

      result.console.push({ type: consoleMessage.type(), text: consoleMessage.text() })
    })
    await page.goto(url)

    result.elements = await page.evaluate(() => {
github hfreire / facebook-login-for-robots / src / facebook-login-for-robots.js View on Github external
.then(() => {
        const url = buildUrl(clientId, redirectUri, options)

        return RandomHttpUserAgent.get()
          .then((userAgent) => this._perseverance.exec(() => doLogin.bind(this)(url, redirectUri, userAgent)))
      })
  }
github hfreire / get-me-a-date / src / channels / auth / facebook.js View on Github external
authorizeApp (email, password, url) {
    Logger.debug('Started authorizing app in Facebook')

    return RandomUserAgent.get()
      .then((userAgent) => this._authorizeAppCircuitBreaker.exec(email, password, url, userAgent))
      .finally(() => Logger.debug('Finished authorizing app in Facebook'))
  }
}
github hfreire / watch-rtp-play / src / http-request.js View on Github external
get (url, headers = {}, tor = false) {
    if (!url) {
      return Promise.reject(new Error('invalid arguments'))
    }

    const options = { url }

    if (tor) {
      const agentClass = _.startsWith(url, 'https') ? require('socks5-https-client/lib/Agent') : require('socks5-http-client/lib/Agent')
      const agentOptions = this._options.socks

      _.merge(options, { agentClass, agentOptions })
    }

    return RandomUserAgent.get()
      .then((userAgent) => {
        options.headers = _.assign({}, headers, { 'User-Agent': userAgent })

        return this._request.getAsync(options)
      })
  }
}

random-http-useragent

Get a random and legit user-agent for your HTTP client

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular random-http-useragent functions

Similar packages