Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. function joub(){
  2. (async function() {
  3. const instance = await phantom.create();
  4. const page = await instance.createPage();
  5. await page.on('onResourceRequested', function(requestData) {
  6. console.info('Requesting', requestData.url);
  7. });
  8.  
  9.  
  10. const status = await page.open('WebUrlForScrapping'); //Link donde hace el scrapping
  11. const JobsListing = await page.evaluateJavaScript('function() { return document.getElementById('task-listing-datatable').getAttribute("data-tasks"); }') //Me saca la lista de jobs del div que contine el id task-listing-datatable y saco la lista de job completa del atributo data-tasks, eso lo obtiene como un string y lo paso a minuscula
  12. .then(function(dataJobs){
  13. var dataJobsArr = eval(dataJobs);
  14. return dataJobsArr; //retorna el query del data tasks
  15. });
  16.  
  17. var keyword = ['Review Annotated Buildings'];
  18. for(let i=0; i<JobsListing.length; i++){
  19. for(let j=0; j<keyword.length; j++){
  20. if(JobsListing[i][1] === keyword[j]){
  21. client.on('message', (message)=>{
  22.  
  23. if (message.content === "Bot start"){
  24. if(message.author.bot === false) {
  25. message.channel.send(`${JobsListing[i][0]} ${JobsListing[i][1]} Paga ${JobsListing[i][3]} Tareas: ${JobsListing[i][5]}`);
  26. }
  27. };
  28.  
  29. }
  30. );
  31. }
  32. }
  33. }
  34.  
  35. await instance.exit();
  36. })();
  37. }
  38. setInterval(joub, 10000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement