Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find phone numbers #10

Closed
kristofferremback opened this issue Jan 17, 2016 · 1 comment
Closed

Find phone numbers #10

kristofferremback opened this issue Jan 17, 2016 · 1 comment

Comments

@kristofferremback
Copy link
Owner

Use zombie.js to do this.

Might need wrapping inside a try/catch block as it sometimes fails

'use strict' 

var Browser = require('zombie');

var url = 'http://www.blocket.se/stockholm/Lindvallen___Gubbmyren_mysig_stuga_64817356.htm';

var _url = url.replace(/www(?=\.blocket\.se)/, 'm');

console.log(url);
console.log(_url);

var browser = new Browser({ debug: true });

browser.visit(_url, function (e, a) {

  var phoneLink = browser.document.querySelector('#show-phonenumber');

  // Check link exists
  if (phoneLink) {
    browser.clickLink('#show-phonenumber')
    .then(function () {

      var phoneNumber = browser.document.querySelector('#show-phonenumber .button-label');

      console.log(phoneNumber.textContent);
    })
    .catch(function (err) {
      console.log(err);
    });
  } else {
    console.log('No link found.');
  }

})
@kristofferremback
Copy link
Owner Author

This seems to not work properly just yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant