@rent-scraper/api 1.0.41 → 1.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +1 -1
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -2458,4 +2458,4 @@ fragment RentalPrequalificationCard on ABTests {
2458
2458
  }
2459
2459
  }
2460
2460
  }
2461
- `},{data:o}=await c.post(t,r,{headers:C})||{};return o?.data?.property},I=(e,t)=>e===403&&t?.includes("captcha"),pe=e=>K(e),X=async e=>{const{data:t}=await c.post("http://localhost:8082/browser/open",{url:e});return t?.browser},D=async()=>{const{data:e}=await c.post("http://localhost:8082/browser/status");return e?.browser},_e=async()=>{try{return(await D())?.status==="captcha"}catch{return!1}},P=async()=>{await c.post("http://localhost:8082/cookie/refresh")},$=async(e,t=0)=>{try{await v()||T("zip codes required, please run the createConfig script");const{fetchListings:r=!1}=e??{},o=3101,{results:a}=await k({regionId:o,daysOnZillow:1,mergePageResults:!1})??{},{zpid:i,detailUrl:s}=a?.[0]??{};return i&&r?await Z(i):a?.length&&!r||(s&&!s.startsWith("/apartments")?await S(s):t<5?await $(e,t+1):T("Could not find a valid listing URL to check for bot filtering.")),!0}catch(r){const{status:o,message:a}=H(r);I(o,a)&&T("Zillow bot filtering! Please open https://zillow.com in your browser and complete the challenge to continue.")}},Y=async()=>{const{data:e}=await c.post("http://localhost:8082/captcha/solve");return e?.solved===!0},de=async()=>{let e=!1,t=!1;for(;;){try{if(e){if((await D())?.status==="navigated")return await P(),!0;!t&&await R()&&(t=!0,await Y(),t=!1)}else{const r=await X("https://www.zillow.com/homes/for_rent/");if(r?.status==="captcha")e=!0;else if(r?.status==="navigated")return await P(),!0}}catch{}await new Promise(r=>setTimeout(r,e?500:100))}},ce=async()=>{let e=!1,t=null,r=!1,o=0;const a=100,i=Date.now()+600*1e3;for(;;){if(Date.now()>i)throw new Error("timed out waiting for captcha solve");try{if(e){if((await D())?.status==="navigated"&&(t?Date.now()-t:0)>=3500)return await P(),!0;if(!r&&await R()){r=!0,await Y();continue}}else{const s=await X("https://www.zillow.com/homes/for_rent/");if(s?.status==="captcha")e=!0,t=Date.now();else if(s?.status==="navigated"&&(o++,o>=a))return await P(),!0}}catch{}await new Promise(s=>setTimeout(s,e?500:2e3))}},q=()=>{const e=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15"],t=Math.floor(Math.random()*e.length);return e[t]},ye=async(e,t)=>{const r=await j.launch({headless:!0,timeout:1e5,defaultViewport:null}),o=await r.newPage();if(e.includes("file://"))await o.setJavaScriptEnabled(!1);else{const i=q();await o.setUserAgent(i)}await o.goto(e,{waitUntil:"networkidle2"});const a=await o.evaluate(()=>document.querySelector(".layout-content-container")?.clientHeight);a&&await o.setViewport({width:1024,height:a}),await o.screenshot({path:t,fullPage:!0,captureBeyondViewport:!0}),await o.close(),await r.close(),console.log(`screenshot complete, ${t}`)},me=e=>{if(e==null||typeof e!="object")return!1;const t=e;return!(t.address===void 0||typeof t.bedrooms!="number"||typeof t.bedrooms!="number"||typeof t.daysOnZillow!="number"||typeof t.hdpUrl!="string"||typeof t.homeStatus!="string"||typeof t.homeType!="string"||typeof t.isRentalListingOffMarket!="boolean"||typeof t.price!="number"||typeof t.timeOnZillow!="string"||typeof t.zipcode!="string"||typeof t.zpid!="number")};export{$ as checkForZillowBotFiltering,w as fetchHtmlFromRedfinListingUrl,S as fetchHtmlFromZillowListingUrl,G as fetchRedfinListingResults,f as fetchRedfinRegionIdByZipCode,E as fetchZillowListingResults,q as generateRandomUA,J as getHtmlFromRedfinListingUrl,oe as getHtmlFromZillowListingUrl,pe as getRandomZipCode,ee as getRedfinListingDetailsById,te as getRedfinListingResults,V as getRedfinRegionIdByZipCode,R as getZillowAutoCaptcha,A as getZillowCookie,le as getZillowListingContactDetailsByZpid,Z as getZillowListingDetailsByZpid,k as getZillowListingResults,x as getZillowRegionIdByZipCode,v as getZillowZipCodes,_e as isBrowserShowingCaptcha,I as isZillowBotFiltering,me as isZillowListingForRow,g as parseRedfinResponse,U as scrapeDataFromRedfinListingHtml,B as scrapeDataFromRedfinListingUrl,W as scrapeDataFromZillowListingHtml,ae as scrapeDataFromZillowListingUrl,ye as screenshotZillowListing,de as waitForSolvedZillowCaptcha,ce as waitForZillowCaptchaSolve,z as zillowListingResultsHeaders};
2461
+ `},{data:o}=await c.post(t,r,{headers:C})||{};return o?.data?.property},I=(e,t)=>e===403&&t?.includes("captcha"),pe=e=>K(e),X=async e=>{const{data:t}=await c.post("http://localhost:8082/browser/open",{url:e});return t?.browser},D=async()=>{const{data:e}=await c.post("http://localhost:8082/browser/status");return e?.browser},_e=async()=>{try{return(await D())?.status==="captcha"}catch{return!1}},P=async()=>{await c.post("http://localhost:8082/cookie/refresh")},$=async(e,t=0)=>{try{await v()||T("zip codes required, please run the createConfig script");const{fetchListings:r=!1}=e??{},o=3101,{results:a}=await k({regionId:o,daysOnZillow:1,mergePageResults:!1})??{},{zpid:i,detailUrl:s}=a?.[0]??{};return i&&r?await Z(i):a?.length&&!r||(s&&!s.startsWith("/apartments")?await S(s):t<5?await $(e,t+1):T("Could not find a valid listing URL to check for bot filtering.")),!0}catch(r){const{status:o,message:a}=H(r);I(o,a)&&T("Zillow bot filtering! Please open https://zillow.com in your browser and complete the challenge to continue.")}},Y=async()=>{const{data:e}=await c.post("http://localhost:8082/captcha/solve");return e?.solved===!0},de=async()=>{let e=!1,t=!1;for(;;){try{if(e){if((await D())?.status==="navigated")return await P(),!0;!t&&await R()&&(t=!0,await Y(),t=!1)}else{const r=await X("https://www.zillow.com/homes/for_rent/");if(r?.status==="captcha")e=!0;else if(r?.status==="navigated")return await P(),!0}}catch{}await new Promise(r=>setTimeout(r,e?500:100))}},ce=async()=>{let e=!1,t=null,r=!1,o=0;const a=100,i=Date.now()+600*1e3;for(;;){if(Date.now()>i)throw new Error("timed out waiting for captcha solve");try{if(e){if((await D())?.status==="navigated"&&(t?Date.now()-t:0)>=3500)return await P(),!0;if(!r&&await R()){r=!0,await Y()||(r=!1);continue}}else{const s=await X("https://www.zillow.com/homes/for_rent/");if(s?.status==="captcha")e=!0,t=Date.now();else if(s?.status==="navigated"&&(o++,o>=a))return await P(),!0}}catch{}await new Promise(s=>setTimeout(s,e?500:2e3))}},q=()=>{const e=["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15","Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15"],t=Math.floor(Math.random()*e.length);return e[t]},ye=async(e,t)=>{const r=await j.launch({headless:!0,timeout:1e5,defaultViewport:null}),o=await r.newPage();if(e.includes("file://"))await o.setJavaScriptEnabled(!1);else{const i=q();await o.setUserAgent(i)}await o.goto(e,{waitUntil:"networkidle2"});const a=await o.evaluate(()=>document.querySelector(".layout-content-container")?.clientHeight);a&&await o.setViewport({width:1024,height:a}),await o.screenshot({path:t,fullPage:!0,captureBeyondViewport:!0}),await o.close(),await r.close(),console.log(`screenshot complete, ${t}`)},me=e=>{if(e==null||typeof e!="object")return!1;const t=e;return!(t.address===void 0||typeof t.bedrooms!="number"||typeof t.bedrooms!="number"||typeof t.daysOnZillow!="number"||typeof t.hdpUrl!="string"||typeof t.homeStatus!="string"||typeof t.homeType!="string"||typeof t.isRentalListingOffMarket!="boolean"||typeof t.price!="number"||typeof t.timeOnZillow!="string"||typeof t.zipcode!="string"||typeof t.zpid!="number")};export{$ as checkForZillowBotFiltering,w as fetchHtmlFromRedfinListingUrl,S as fetchHtmlFromZillowListingUrl,G as fetchRedfinListingResults,f as fetchRedfinRegionIdByZipCode,E as fetchZillowListingResults,q as generateRandomUA,J as getHtmlFromRedfinListingUrl,oe as getHtmlFromZillowListingUrl,pe as getRandomZipCode,ee as getRedfinListingDetailsById,te as getRedfinListingResults,V as getRedfinRegionIdByZipCode,R as getZillowAutoCaptcha,A as getZillowCookie,le as getZillowListingContactDetailsByZpid,Z as getZillowListingDetailsByZpid,k as getZillowListingResults,x as getZillowRegionIdByZipCode,v as getZillowZipCodes,_e as isBrowserShowingCaptcha,I as isZillowBotFiltering,me as isZillowListingForRow,g as parseRedfinResponse,U as scrapeDataFromRedfinListingHtml,B as scrapeDataFromRedfinListingUrl,W as scrapeDataFromZillowListingHtml,ae as scrapeDataFromZillowListingUrl,ye as screenshotZillowListing,de as waitForSolvedZillowCaptcha,ce as waitForZillowCaptchaSolve,z as zillowListingResultsHeaders};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rent-scraper/api",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
@@ -31,7 +31,7 @@
31
31
  "cheerio": "^1.1.0",
32
32
  "dayjs": "^1.11.13",
33
33
  "puppeteer": "^24.11.2",
34
- "@rent-scraper/utils": "1.0.41"
34
+ "@rent-scraper/utils": "1.0.42"
35
35
  },
36
36
  "devDependencies": {
37
37
  "unbuild": "^3.5.0",