Skip to content

Instantly share code, notes, and snippets.

@Daymannovaes
Created May 5, 2017 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daymannovaes/419d2a6ee67e63c3a60b6cb0a301d37f to your computer and use it in GitHub Desktop.
Save Daymannovaes/419d2a6ee67e63c3a60b6cb0a301d37f to your computer and use it in GitHub Desktop.
http://mg.olx.com.br/belo-horizonte-e-regiao/eletrodomesticos?f=p&pe=1200&ps=800&q=geladeira
results = $('#main-ad-list li:not(.list_native)').map((a, i) => {
let $f = $(i).find.bind($(i));
return {
href: $f('a')[0].href,
title: $f('h3').text().trim(),
price: $f('.OLXad-list-price').text().trim().replace(/R\$ ?/, '').replace(/\./, ','),
region: $f('.detail-region').text().trim().replace(/\n/g, '').replace(/\t/g, '').replace(/ +/g, ' '),
time: $f('.col-4').text().trim().replace(/\n/g, '').replace(/\t/g, '').replace(/ +/g, ' '),
}
});
results.toArray().map(({ href, title, price, region, time }) => `${title} ${price} ${region} ${time} ${href}`).join('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment