pevers / images-scraper

Simple and fast scraper for Google
ISC License
224 stars 69 forks source link

how to avoid nsfw content #60

Closed zortos293 closed 3 years ago

zortos293 commented 3 years ago

i want to turn of nsfw content so that it doesn't popup on discord how can i do that

pevers commented 3 years ago

It is currently not supported. But I'm open for pull requests.

A naive approach would be "clicking" the toggle in the mainscreen via the headless browser.

MarceloBrazolim commented 3 years ago

for a quick fix you could just add "&safe=active" in the searchQuery since there is no formating or treatment at line 42 Screenshot_8

I already made a pull request with these alterations.

for a future version it could be solved with this (I already tested and it works just fine):

constructor({
    safe = false,
  } = {}) {
    this.safe = this._isQuerySafe(safe);
  }

_isQuerySafe(safe) {
  if (safe === true) {
    return '&safe=active';
  } else return '';
}

async scrape(searchQuery, limit = 100) {
  const query = `https://www.google.com/search?q=${searchQuery}&source=lnms&tbm=isch${this.safe}&sa=X&tbs=${this.tbs}`;
}

also, why is there a "Logger.info()" below the definition of the query variable? it just floods my console since i like to use a customized console and it ruins the flow :v Screenshot_9

pevers commented 3 years ago

for a quick fix you could just add "&safe=active" in the searchQuery since there is no formating or treatment at line 42 Screenshot_8

I already made a pull request with these alterations.

for a future version it could be solved with this (I already tested and it works just fine):

constructor({
    safe = false,
  } = {}) {
    this.safe = this._isQuerySafe(safe);
  }

_isQuerySafe(safe) {
  if (safe === true) {
    return '&safe=active';
  } else return '';
}

async scrape(searchQuery, limit = 100) {
  const query = `https://www.google.com/search?q=${searchQuery}&source=lnms&tbm=isch${this.safe}&sa=X&tbs=${this.tbs}`;
}

Thanks! This indeed solves it! I've merged it and I'll create a new release.

also, why is there a "Logger.info()" below the definition of the query variable? it just floods my console since i like to use a customized console and it ruins the flow :v Screenshot_9

This is a mistake. I'll fix it. Thanks for reporting

pevers commented 3 years ago

I'm closing this. Feature added in 6.1