English 中文(简体)
单相连接的校正数据
原标题:Scrape data from a socket connection

我曾试图从一个使用袖珍的网站上删除数据。 现场更新。 如果能够做到这一点,那将是很 hand。

Most of the work performed by the socket layer is in sending and receiving data. The socket layer itself explicitly refrains from imposing any structure on data transmitted or received through sockets.

Im试图从网站。 然而,我尝试了以下法典,除一条连接外,还没有收到任何最新情况:

var io = require("socket.io-client");
var socket = io("https://www.coinscrash.com");

socket.on("connect", function () {
  console.log(true);
});

socket.on("msg", function (data) {
  console.log("chat message");
});

socket.on("disconnect", function () {
  console.log(false);
});

socket
  .on("error", (err) => console.log(err))
  .on("connect_error", (err) => console.log(err));

我做了一些错误,还是不可能这样做?

问题回答

我不认为您的报废方法是可行的。 你在你的法典中做了许多毫无根据的假设。 我将解释我用来收集有关袖珍连接的信息并将其余部分留给你的方法。 我也试图纠正你的错误,但没有成功。

Inspecting packets

通过开放该网络和申请表,将 Chrome光投射工具用于<代码>https://formscrash.com/play,我们可以获得大量有关袖珍连接的信息:

https://game.coinscrash.com/socket.io/?EIO=3&transport=polling&t=OoRA8bm&sid=YTATw0ot9MvDA542ABdY
  • Cookies are involved in this connection: enter image description here
  • The transport type is polling:

“entergraph

Inspecting socket event names from website code

我们可以从“黄 Chrome”衍生工具的表格中获取以下信息:main-new-a35c0ce7.j:

  • The client emits a ping event and expects a pong event from server within some delay: enter image description here

Why your code does not work

var socket = io( https://www.coinscrash.com )

<代码>https://www. Chemscrash.com上没有任何链接。 如前所述,接头连接的服务器有:URL

假设你能够与服务器连接起来,那么你的代码仍然不会奏效,因为活动名称msg是不正确的:

socket.on( msg , function(data) {
console.log( chat message );
});

客户应当期待举办<代码>pong活动。

My failed attempt

首先,我正在吉大港山区开发商服务器上操作该代码,以便不断监测地表连接。 如果没有服务器,你的代码将一劳永逸。

// setup server
const http = require("node:http");
const hostname = "127.0.0.1";
const port = 3000;
const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader("Content-Type", "text/plain");
  res.end("Hello World
");
});
server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

const BACKEND_URL = "https://game.coinscrash.com/socket.io/";

const { io } = require("socket.io-client");
const socket = io(BACKEND_URL, {
  reconnectionDelayMax: 10000,
  autoConnect: false,
  transports: ["polling", "websocket"],
  withCredentials: true, // includes cookies in socket
});

// Adds a listener that will be fired when any event is emitted.
socket.on("connect", () => {
  console.log(socket.id);
});

// Adds a listener that will be fired when any event is emitted.
socket.onAny((eventName, ...args) => {
  console.log(eventName);
});

我的法典仍然未能与袖珍服务连接,这很可能是因为该法典没有将所需的厨师送至硬币服务器。

Final thoughts

在本案中,直接与单列服务连接并非直截了当,因为可能有些基于会议认证(使用厨师)出现在单料服务器上。 由于你重新利用了NodeJS的基本环境,你无法通过认证。

此外,最令人费解的是,即使你在前端网站,例如,在当地网站上管理,但书状连接不会成功,但书状的配置却只能用其域名进行。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签