You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

apartments.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var request = require('request').defaults({ encoding: null });
  2. module.exports.apartment = function($) {
  3. var result = {
  4. // images: request.get($('.aspectRatioImage').find('img')[0].attribs.src, function (error, response, body) {
  5. // if (!error && response.statusCode == 200) {
  6. // data = "data:" + response.headers["content-type"] + ";base64," + Buffer.from(body).toString('base64');
  7. // return data;
  8. // }
  9. // }),
  10. name: $('#propertyName').text(),
  11. description: $('#descriptionSection>p').html(),
  12. address: {
  13. street: $('.propertyAddressContainer h2>span:nth-child(1)').text(),
  14. city: $('.propertyAddressContainer h2>span:nth-child(2)').text(),
  15. zip: {
  16. state: $('.propertyAddressContainer .stateZipContainer>span:nth-child(1)').text(),
  17. code: $('.propertyAddressContainer .stateZipContainer>span:nth-child(2)').text(),
  18. }
  19. },
  20. contact: {
  21. phone: $('.contactInfo .phoneNumber span').html(),
  22. language: $('.contactInfo .languages span').html(),
  23. url: $('.contactInfo .mortar-wrapper a').attr('href'),
  24. officeHours: $('.daysHoursContainer').map(function () {
  25. return {
  26. days: $(this).find('.days').text(),
  27. hours: $(this).find('.hours').text(),
  28. };
  29. }).get()
  30. },
  31. features: $('#uniqueFeatures .uniqueAmenity').map(function () {
  32. return $(this).find('span').text();
  33. }).get(),
  34. prices: $('[data-tab-content-id=all]>.pricingGridItem').add('[data-tab-content-id=all]>.jsAvailableModels').map(function () {
  35. return {
  36. name: $(this).find('.modelName').text(),
  37. available: $(this).hasClass('pricingGridItem'),
  38. rent: $(this).find('.rentLabel').text(),
  39. details: {
  40. rooms: $(this).find('.detailsTextWrapper>span:nth-child(1)').text(),
  41. baths: $(this).find('.detailsTextWrapper>span:nth-child(2)').text(),
  42. area: $(this).find('.detailsTextWrapper>span:nth-child(3)').html(),
  43. available: $(this).find('.availabilityInfo').html(),
  44. },
  45. plan: $(this).find('.allAmenities>li').map(function () {
  46. return {
  47. title: $(this).find('.topAmenity').html(),
  48. amenities: $(this).find('.amenity').map(function () {
  49. return $(this).text();
  50. }).get(),
  51. };
  52. }).get(),
  53. };
  54. }).get()
  55. };
  56. var data = JSON.parse(JSON.stringify(result)
  57. .split(' ').join('')
  58. .split(' ').join('')
  59. .split(' ').join('')
  60. .split(' ').join('')
  61. .split('\\n').join(''));
  62. return data;
  63. }