75
2022-11-15 20:16:44 75阅读 0喜欢
const dgram = require("dgram");
const client = dgram.createSocket('udp4');

client.send('客户端发起的信息!', 41234, 'localhost', (err) => {
    client.close();
});

https://nodejs.org/api/dgram.html#event-close

2022-11-13 10:28:47 126阅读 0喜欢
783访问人次
Camila Waz 2022-01-22 18:22:10
61
2022-11-10 21:34:35 61阅读 0喜欢
const http = require('http');
const fs = require('fs');
http.createServer(function (req, res) {

    (async () => {
        const file = fs.readFileSync('log.txt');
        console.log(file.toString())
    })();

    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.write('Node.js says hello!');
    res.end();
}).listen(8080);
2022-11-09 19:59:13 17阅读 0喜欢
81
2022-11-06 13:48:22 81阅读 0喜欢
import { test, expect } from '@playwright/test';

test('test', async ({ page, context }) => {
  //在创建/导航页面之前开始跟踪
  const obj = {
    screenshots: true,
    snapshots: true,
    sources: true
  }
  await context.tracing.start(obj)

  await page.goto('http://good1230.com/');
  //遍历菜单
  const count = await page.locator('ul.width-135 > a.none-line').count();
  const rows = await page.locator('ul.width-135 > a.none-line');

  for (let i = 0; i < count; ++i) {
    await rows.nth(i).click()
    await expect(page).toHaveURL(page.url());
    console.log(page.url())
  }
  // 停止跟踪并将其导出到 zip 存档中。
  await context.tracing.stop({ path: "trace.zip" })
});
31
116
2022-10-27 22:38:31 116阅读 0喜欢

https://playwright.dev/docs/api/class-playwright

https://github.com/microsoft/playwright

const http = require('http');
http.createServer(function (req, res) {

  const { chromium, firefox, webkit } = require('playwright');
  (async () => {
    const browser = await chromium.launch();  // Or 'firefox' or 'webkit'.
    const page = await browser.newPage();
    await page.goto('http://www.good1230.com');
    await page.screenshot({ path: `screenshot.png` }); // 图片默认保存到同当前文件的目录下
    // other actions...
    await browser.close();
  })();

  res.writeHead(200, {'Content-Type': 'text/html'}); 
  res.write('Node.js says hello!');
  res.end();

}).listen(8080);
2019-11-16 12:13:31 34阅读 0喜欢