1"use strict";(self.webpackChunkmicrolink_www=self.webpackChunkmicrolink_www||[]).push([[16631],{85568:function(e,n,t){t.r(n),t.d(n,{Head:function(){return g},default:function(){return $}});var r=t(28453),i=t(96540),o=t(98868),s=t(96211);function l(e){const n=Object.assign({p:"p",ul:"ul",li:"li",strong:"strong",code:"code",a:"a"},(0,r.R)(),e.components);return i.createElement(i.Fragment,null,i.createElement(n.p,null,"Type: ",i.createElement(s.a,null,i.createElement(s.Z,{children:"<string>"})," | ",i.createElement(s.Z,{children:"<string[]>"})),i.createElement("br"),"\nDefault: ",i.createElement(s.Z,{children:"'auto'"}),i.createElement("br"),"\nValues: ",i.createElement(s.a,null,i.createElement(s.Z,{children:"'load'"})," | ",i.createElement(s.Z,{children:"'domcontentloaded'"})," | ",i.createElement(s.Z,{children:"'networkidle0'"})," | ",i.createElement(s.Z,{children:"'networkidle2'"}))),"\n",i.createElement(n.p,null,"Tell the browser to wait until the target website emits one or more event(s) to consider navigation succeeded."),"\n",i.createElement(n.p,null,"The events that can be waited are:"),"\n",i.createElement(n.ul,null,"\n",i.createElement(n.li,null,i.createElement(n.strong,null,"auto"),": A smart combination of ",i.createElement(n.code,null,"'load'")," and ",i.createElement(n.code,null,"'networkidle2'"),"."),"\n",i.createElement(n.li,null,i.createElement(n.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event"},i.createElement(n.strong,null,"load")),": It considers navigation successful when the whole page, including all dependent resources such as stylesheets images, have been loaded. In certain cases, it might not happen at all."),"\n",i.createElement(n.li,null,i.createElement(n.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event"},i.createElement(n.strong,null,"domcontentloaded")),": It's fired as soon as the page DOM has been loaded, without waiting for resources to finish loading."),"\n",i.createElement(n.li,null,i.createElement(n.strong,null,"networkidle0"),": It considers navigation successful when the page has had no network activity for half a second. This might never happen if the page is constantly loading multiple resources."),"\n",i.createElement(n.li,null,i.createElement(n.strong,null,"networkidle2"),": It considers navigation successful when the page has no more then 2 network requests for half a second. This is useful if page runs a long polling in the background."),"\n"),"\n",i.createElement(o.G,{mqlCode:{url:"https://dev.to",screenshot:!0,waitUntil:"domcontentloaded"}}),"\n",i.createElement(n.p,null,"Different arguments work for different pages. When neither of them work, a good solution would be to navigate with ",i.createElement(s.Z,{children:"'domcontentloaded'"})," argument and then simply wait for the needed element to appear on page."),"\n",i.createElement(o.G,{mqlCode:{url:"https://dev.to",screenshot:!0,waitUntil:"domcontentloaded",waitForSelector:"h1"}}))}var a=function(e={}){const{wrapper:n}=Object.assign({},(0,r.R)(),e.components);return n?i.createElement(n,e,i.createElement(l,e)):l(e)},c=t(29451),u=t(55140),d=t(44310),p=t(64810),m=t(50754),h=t(55267);const g=({pageContext:e,location:n})=>{const{description:t,isDocPage:r,isBlogPage:o,frontmatter:s={},lastEdited:l}=e,a=(0,p.GR)("502257632"),m=(0,u.Q)(),{name:h}=m;if(r||o){const e=(0,c.v1)(n),u=s.date&&!isNaN(new Date(s.date).getTime())?s.date:void 0,p=l&&!isNaN(new Date(l).getTime())?l:u,m={...s,description:t,name:r?"Guides"===e?"Microlink Guides":"Microlink Docs":"Microlink Blog",title:r?"Guides"===e?s.title||"":`${h} ${e}: ${s.title||""}`:s.title,publishedDate:u,modifiedDate:p,schemaType:o?"Article":"TechArticle",authors:o?(e=>{const n=new Map(((null==a||null===(e=a.allAuthorsYaml)||void 0===e?void 0:e.nodes)||[]).map(e=>[e.key,e.name]));return(s.authors||[]).flatMap(e=>{const t=n.get(e);return t?[t]:[]})})():void 0};return i.createElement(d.A,m)}return i.createElement(d.A,s)},f=({pageContext:e,children:n,...t})=>{var r;const{isDocPage:o,isBlogPage:s,lastEdited:l,githubUrl:a,frontmatter:c={}}=e,u=null!==(r=c.date)&&void 0!==r?r:l;return o?i.createElement(h.A,Object.assign({title:c.title,isPro:c.isPro,date:u,content:n,githubUrl:a}
1,t)):i.createElement(m.A,Object.assign({title:c.title,subtitle:c.subtitle,authors:c.authors,date:u&&new Date(u),lastEdited:c.lastEdited?l:null,isBlogPage:s,content:n},t))};function $(e){return i.createElement(f,e,i.createElement(a,e))}},88976:function(e,n,t){t.d(n,{P_:function(){return s},Zv:function(){return m},gP:function(){return o}});var r=t(54506);const i=e=>e?"https://pro.microlink.io":"https://api.microlink.io",o=(e,n={})=>{if(!e||"string"!=typeof e)throw new Error("URL parameter is required and must be a string");const{binding:t,...r}=n;return{CLI:w(e,r),cURL:j(e,r),JavaScript:h(e,n),Python:f(e,r),Ruby:$(e,r),PHP:b(e,r),Golang:y(e,r)}},s=e=>`import createClient from 'microlink.io'\n\nconst microlink = createClient(${e?`{ apiKey: ${JSON.stringify(e)} }`:""})`,l=["markdown","html","text"],a={emails:{selector:"html",attr:"html",type:"email"},links:{selectorAll:"a",attr:"href",type:"url"},images:{selectorAll:"img",attr:"src",type:"url"}},c=e=>(0,r.A)(new Set(e.map(e=>e.split(".")[0]))),u=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase(),d=e=>{const{apiKey:n,meta:t,filter:r,embed:i,...o}=e,s=((e,n)=>{if("string"==typeof n){const e=n.split(",").map(e=>e.trim()).filter(e=>e&&"insights"!==e);if(e.length>0)return c(e)}if(null!==e&&"object"==typeof e){const n=Object.keys(e).filter(n=>e[n]);if(n.length>0)return c(n)}})(t,r);var d,p,m;if(null!==o.headers&&"object"==typeof o.headers&&(o.headers=(d=o.headers,Object.fromEntries(Object.entries(d).map(([e,n])=>[e.toLowerCase().startsWith("x-api-header-")?e.toLowerCase():`x-api-header-${u(e)}`,n])))),o.screenshot&&o.pdf){const{screenshot:e,pdf:n,...t}=o,r={method:"screenshot",binding:"screenshot",opts:{...!0===e?{}:e,...t}},i={method:"pdf",binding:"pdf",opts:{...!0===n?{}:n,...t}},s=Object.keys(o);return s.indexOf("pdf")<s.indexOf("screenshot")?[i,r]:[r,i]}if(o.screenshot){const{screenshot:e,...n}=o;return[{method:"screenshot",binding:"data",opts:{...!0===e?{}:e,...n}}]}if(o.pdf){const{pdf:e,...n}=o;return[{method:"pdf",binding:"data",opts:{...!0===e?{}:e,...n}}]}if(o.video){const{video:e,...n}=o;return[{method:"video",binding:"data",opts:{...!0===e?{}:e,...n}}]}if(o.audio){const{audio:e,...n}=o;return[{method:"audio",binding:"data",opts:{...!0===e?{}:e,...n}}]}if(o.insights){const{insights:e,...n}=o,t=[];return(!0===e||e.technologies)&&t.push({method:"technologies",binding:"technologies",opts:n}),(!0===e||e.lighthouse)&&t.push({method:"lighthouse",binding:"report",opts:n}),0===t.length&&"object"==typeof e&&0===Object.keys(e).length&&t.push({method:"technologies",binding:"technologies",opts:n},{method:"lighthouse",binding:"report",opts:n}),t}if(o.iframe){const{iframe:e,palette:n,...t}=o,r=[{method:"embed",binding:"{ html }",opts:{...!0===e?{}:e,...t}}];return n&&r.push({method:"metadata",binding:"{ image, logo }",opts:{palette:n}}),r}if(o.data){const{data:e,...n}=o;if((e=>{const n=Object.keys(e);if(1!==n.length||!l.includes(n[0]))return!1;const t=e[n[0]];return null!==t&&"object"==typeof t&&t.attr===n[0]&&Object.keys(t).every(e=>"attr"===e||"selector"===e)})(e)){const t=Object.keys(e)[0],{selector:r}=e[t];return[{method:t,binding:t,opts:{...r&&{selector:r},...n}}]}const t=(e=>{const n=Object.keys(e);if(1!==n.length)return null;const t=n[0],r=a[t],i=e[t];return r&&i&&"object"==typeof i&&i.type===r.type?t:null})(e);if(t){return[{method:t,binding:t,opts:{...(p=e[t],m=a[t],Object.fromEntries(Object.entries(p).filter(([e,n])=>n!==m[e]))),...n}}]}return[{method:"extract",binding:`{ ${(s||(i?c([i]):Object.keys(e))).join(", ")} }`,rules:e,opts:n}]}if("string"==typeof o.function){const{function:e,binding:n,...t}=o;return[{method:"function",binding:n||"{ value }",fn:e,opts:t}]}return[{method:"metadata",binding:"data",opts:o}]},p=(e,{method:n,binding:t,fn:r,rules:i,opts:o})=>{const s=Object.keys(o).length>0,l=(e=>`'${String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}'`)(e);if("function"===n){const e=`const ${t} = await microlink.function(${l}, ${r})`;if(!s&&!r.includes("\n")&&e.length<=80)return e;const n=[l,r.split("\n").join("\n ")];return s&&n.push(g(o,2)),`const ${t} = await microlink.function(\n ${n.join(",\n ")}\n)`}if("extract"===n){const e=[l,g(i,0)];return s&&e.push(g(o,0)),`const ${t} = await microlink.extract(${e.join(", ")})`}const a=s?`await microlink.${n}(${l}, ${g(o,0)})`:`await microlink.${n}(${l})`,c=`const ${t} = ${a}`;return!s&&c.length>80?`const ${t} =\n ${a}`:c},m=(e,n={})=>d(n).map(n=>p(e,n)).join("\n\n"),h=(e,n={})=>`${s(n.apiKey)}\n\n${m(e,n)}`,g=(e,n=0)=>
1{if(null===e)return"null";if(void 0===e)return"undefined";if("string"==typeof e)return e.includes('"')&&!e.includes("'")?`'${e}'`:e.includes('"')?`"${e.replace(/"/g,'\\"')}"`:`"${e}"`;if("number"==typeof e||"boolean"==typeof e)return String(e);if(Array.isArray(e)){if(0===e.length)return"[]";const t=e.map(e=>g(e,n+2));return`[\n${" ".repeat(n+2)}${t.join(`,\n${" ".repeat(n+2)}`)}\n${" ".repeat(n)}]`}if("object"==typeof e){const t=Object.entries(e);if(0===t.length)return"{}";return`{\n${t.map(([e,t])=>{const r=!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)?`"${e}"`:e,i=g(t,n+2);return`${" ".repeat(n+2)}${r}: ${i}`}).join(",\n")}\n${" ".repeat(n)}}`}return String(e)},f=(e,n={})=>{const{apiKey:t,...r}=n,o={url:e,...E(r)},s=Object.entries(o).map(([e,n])=>{const t=(e=>{const n=String(e);return n.includes('"')||n.includes("'")||n.includes("\\")||n.includes("\n")?`'''${n}'''`:`"${n}"`})(n);return` "${e}": ${t}`}).join(",\n");let l=`import requests\n\nurl = "${i(t)}/"\n\nquerystring = {\n${s}\n}`;return l+=t?`\n\nheaders = {\n "x-api-key": "${t}"\n}\n\nresponse = requests.get(url, params=querystring, headers=headers)`:"\n\nresponse = requests.get(url, params=querystring)",l+="\n\nprint(response.json())",l},$=(e,n={})=>{const{apiKey:t,...r}=n,o={url:e,...E(r)},s=Object.entries(o).map(([e,n])=>{const t=(e=>{const n=String(e);return n.includes('"')&&!n.includes("'")?`'${n}'`:n.includes('"')?`"${n.replace(/"/g,'\\"')}"`:`"${n}"`})(n);return` ${e}: ${t}`}).join(",\n");let l=`require 'uri'\nrequire 'net/http'\n\nbase_url = "${i(t)}/"\n\nparams = {\n${s}\n}\n\nuri = URI(base_url)\nuri.query = URI.encode_www_form(params)\n\nhttp = Net::HTTP.new(uri.host, uri.port)\nhttp.use_ssl = true\n\nrequest = Net::HTTP::Get.new(uri)`;return t&&(l+=`\nrequest['x-api-key'] = "${t}"`),l+="\nresponse = http.request(request)\n\nputs response.body",l},b=(e,n={})=>{const{apiKey:t,...r}=n,o={url:e,...E(r)},s=Object.entries(o).map(([e,n])=>{const t=(e=>{const n=String(e);return n.includes('"')&&!n.includes("'")?`'${n}'`:n.includes('"')?`"${n.replace(/"/g,'\\"')}"`:`"${n}"`})(n);return` "${e}" => ${t}`}).join(",\n");let l=`<?php\n\n$baseUrl = "${i(t)}/";\n\n$params = [\n${s}\n];\n\n$query = http_build_query($params);\n$url = $baseUrl . '?' . $query;\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n CURLOPT_URL => $url,\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => "",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => "GET"`;return t&&(l+=`,\n CURLOPT_HTTPHEADER => [\n "x-api-key: ${t}"\n ]`),l+='\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo "cURL Error #: " . $err;\n} else {\n echo $response;\n}',l},y=(e,n={})=>{const{apiKey:t,...r}=n,o={url:e,...E(r)},s=[],l=[];Object.entries(o).forEach(([e,n],t)=>{const r=String(n);if(r.includes('"')||r.includes("'")||r.includes("\\")||r.includes("\n")){const n="function"===e?"fn":`${e}Param`;s.push(` ${n} := \`${r}\``),l.push(` q.Set("${e}", ${n})`)}else l.push(` q.Set("${e}", "${r}")`)});const a=s.length>0?"\n"+s.join("\n")+"\n":"",c=t?`\n\n req.Header.Set("x-api-key", "${t}")`:"";return`package main\n\nimport (\n "fmt"\n "net/http"\n "net/url"\n "io"\n)\n\nfunc main() {\n baseURL := "${i(t)}"\n\n u, err := url.Parse(baseURL)\n if err != nil {\n panic(err)\n }${a}\n q := u.Query()\n${l.join("\n")}\n u.RawQuery = q.Encode()\n\n req, err := http.NewRequest("GET", u.String(), nil)\n if err != nil {\n panic(err)\n }${c}\n\n client := &http.Client{}\n resp, err := client.Do(req)\n if err != nil {\n panic(err)\n }\n defer resp.Body.Close()\n\n body, err := io.ReadAll(resp.Body)\n if err != nil {\n panic(err)\n }\n\n fmt.Println(string(body))\n}`},E=(e,n="")=>{const t={};for(const[r,i]of Object.entries(e)){const e=n?`${n}.${r}`:r;null===i||"object"!=typeof i||Array.isArray(i)?t[e]=i:Object.assign(t,E(i,e))}return t},w=(e,n={})=>{const{apiKey:t,...r}=n,i=E(r);return`microlink ${e}${Object.entries(i).flatMap(([e,n])=>{if("boolean"==typeof n)return n?`&${e}`:[];const t=(e=>{const n=String(e);return/[\s"'<>&|;()$`\\]/.test(n)?`'${n.replace(/'/g,"'\"'\"'")}'`:n})(n);return`&${e}=${t}`}).join("")}${t?` --api-key ${t}`:""}`},j=(e,n={})=>{const{apiKey:t,...r}=n,o={url:e,...E(r)},s=[`curl -G "${i(t)}"`];return t&&s.push(` -H "x-api-key: ${t}
1"`),Object.entries(o).forEach(([e,n])=>{const t=String(n),r=t.includes(" ")?encodeURIComponent(t):t;s.push(` -d "${e}=${r}"`)}),s.length>1?s.join(" \\\n"):`curl "${i(t)}?url=${encodeURIComponent(e)}"`}},96211:function(e,n,t){t.d(n,{Z:function(){return c},a:function(){return u}});var r=t(63679),i=t(70066),o=t(96540),s=t(40538),l=t(62932);const a=(0,r.default)(l.A).withConfig({displayName:"Type__StyledType",componentId:"sc-9plilg-0"})([""," padding:0.2em 0.4em;margin:0;border-radius:3px;"],(0,i.w4)({bg:"gray1",color:"gray7",fontFamily:"mono",fontSize:0,fontWeight:"regular"})),c=e=>o.createElement(a,Object.assign({as:"span"},e)),u=(0,r.default)(s.A).withConfig({displayName:"Type__TypeContainer",componentId:"sc-9plilg-1"})(["display:inline;"])},98868:function(e,n,t){t.d(n,{G:function(){return i}});var r=t(1590);const i=(0,t(7129).Ub)(r.A)}}]); 2//# sourceMappingURL=component---src-templates-index-js-content-file-path-src-content-docs-api-parameters-wait-until-md-8a31562e3e90783887f8.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.