Back/NodeJS
-
[NodeJs] playwright exampleBack/NodeJS 2022. 12. 17. 19:55
* playwright : headless 브라우저를 지원하는 라이브러리 - chromium 을 통하여 http://httpbin.org/anything 접속한다. const playwright = require("playwright"); (async () => { const browser = await playwright.chromium.launch(); const context = await browser.newContext(); const page = await context.newPage(); await page.goto('http://httpbin.org/anything'); console.log(await page.locator('pre').textContent()); await browser..
-
[NodeJS] cheerio debugBack/NodeJS 2022. 12. 15. 22:49
const cheerio = require("cheerio"); const $ = cheerio.load(pageHTML.data); function initialize(selector, context, root, opts) { html = function html(dom, options) { xml = function xml(dom) { text = function text(elements) { parseHTML = function parseHTML(data, context, keepScripts) { root = function root() { contains = function contains(container, contained) { merge = function merge(arr1, arr2) ..
-
[NodeJs] axios responseBack/NodeJS 2022. 12. 15. 22:32
- axios 를 사용하여 HTTP 요청하기 - axios : promise-based JavaScript HTTP client. const axios = require("axios"); const pageHTML = await axios.get("https://scrapeme.live/shop"); { "status": 200, "statusText": "OK", "headers": { "date": "Thu, 15 Dec 2022 13:19:12 GMT", "server": "Apache/2.4.41 (Ubuntu)", "expires": "Thu, 19 Nov 1981 08:52:00 GMT", "cache-control": "no-store, no-cache, must-revalidate", "..
-
[NodeJS] SyntaxError: await is only valid in async functions and the top level bodies of modulesBack/NodeJS 2022. 12. 15. 22:18
# const pageHTML = await axios.get("https://scrapeme.live/shop"); ^^^^^ SyntaxError: await is only valid in async functions and the top level bodies of modules at Object.compileFunction (node:vm:360:18) at wrapSafe (node:internal/modules/cjs/loader:1088:15) at Module._compile (node:internal/modules/cjs/loader:1123:27) at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) at Module..