"use strict";(()=>{var e={};e.id=3295,e.ids=[3295],e.modules={20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},56681:e=>{e.exports=require("playwright")},57147:e=>{e.exports=require("fs")},71017:e=>{e.exports=require("path")},33628:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>S,patchFetch:()=>A,requestAsyncStorage:()=>f,routeModule:()=>x,serverHooks:()=>b,staticGenerationAsyncStorage:()=>g});var a={};r.r(a),r.d(a,{POST:()=>v});var o=r(49303),i=r(88716),n=r(60670),s=r(87070),l=r(56681),c=r(57147),p=r.n(c),u=r(71017),d=r.n(u);async function w(e=5e3){for(;;)try{if((await fetch("https://www.bing.com",{method:"HEAD",timeout:5e3})).ok)return!0}catch{await new Promise(t=>setTimeout(t,e))}}let m=d().resolve(process.cwd(),".."),h=d().join(m,"data","pvt_temp_data"),y=async(e,t)=>{try{p().existsSync(h)||p().mkdirSync(h,{recursive:!0});let r=t.replace(/[^a-zA-Z0-9]/g,"_"),a=d().join(h,`${r}.json`),o=[];if(p().existsSync(a)){let e=p().readFileSync(a,"utf-8");try{o=JSON.parse(e)}catch(e){o=[]}}let i=[...o,...e];p().writeFileSync(a,JSON.stringify(i,null,2),"utf-8")}catch(e){console.error("❌ Error saving data:",e.message)}};async function v(e){try{let t=new AbortController,r=t.signal;e.signal?.addEventListener("abort",()=>{t.abort()});let{city:a,limit:o=5}=await e.json();if(!a)return s.NextResponse.json({error:"city is required"},{status:400});let i=await l.chromium.connectOverCDP("http://localhost:9222"),n=i.contexts()[0].pages()[0],c=`https://www.zaubacorp.com/company-by-address/${a}`;await n.goto(c,{waitUntil:"domcontentloaded",timeout:6e4}),await n.waitForTimeout(3e3),await n.evaluate(()=>{let e=document.querySelectorAll('nav[aria-label="pagination"] ul li')||[];return e[8]?.querySelector('a[aria-controls="results"]').innerText||""});let p=1,u=[],d=(e,t)=>Math.floor(Math.random()*(t-e+1))+e;for(;p<=o&&!r.aborted;){let e=await n.evaluate(()=>{let e=document.querySelectorAll("table#results tbody tr"),t=[];return e.forEach(e=>{let r=e.querySelectorAll("td")||[],a=r[0]?.innerText||"",o=r[1].querySelector("a")?.href||"",i=r[1]?.innerText||"",n=r[2]?.innerText||"";t.push({cin:a,company_url:o,company_name:i,company_address:n,company_about:"",company_info:[],directors:[],website:"N/A",whatsapp:"N/A",email:"N/A",phone:"N/A",update:"N/A"})}),t}),t=await n.$('a[aria-label="Next"]');if(!e)break;if(!t){console.log('No "Next" button found. Exiting pagination loop.');break}let r=d(2e3,5e3);console.log(`${r}`),await w(),await n.waitForTimeout(r),t.click(),await n.waitForTimeout(r);let o=e.map(e=>({...e,city:a}));await y(o,`${a}`,"pvt_temp_data"),u.push(...o),p++}return await i.close(),s.NextResponse.json(u)}catch(e){return console.error("Scraping Error:",e),s.NextResponse.json({error:"Failed to scrape website"},{status:500})}}let x=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/pvt_scraper/route",pathname:"/api/pvt_scraper",filename:"route",bundlePath:"app/api/pvt_scraper/route"},resolvedPagePath:"C:\\Users\\Design Collection\\OneDrive\\Desktop\\Jitendra Vishwakarma\\Next Dashboard\\web crawler for user dev\\Scrape Genius\\app\\api\\pvt_scraper\\route.js",nextConfigOutput:"",userland:a}),{requestAsyncStorage:f,staticGenerationAsyncStorage:g,serverHooks:b}=x,S="/api/pvt_scraper/route";function A(){return(0,n.patchFetch)({serverHooks:b,staticGenerationAsyncStorage:g})}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972],()=>r(33628));module.exports=a})();