惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - Ivan Zou

示例 - 17行代码实现一个简单高效的多线程蜘蛛程序 示例 - 10行代码在C#中获取页面元素布局信息 Spider Studio 新版本 (20140225) - 设置菜单调整 / 提供JQueryContext布局相关的方法 示例 - 25行代码等价实现 - 借助Nodejs在服务端使用jQuery采集17173游戏排行信息 Spider Studio 新版本 (码年吉祥版) - 浏览器视图 / 脚本库上线! 分享: 利用Readability解决网页正文提取问题 分享一个天气历史数据的采集脚本 分享 - Hybrid 开发将博客园集成到自己的网站中 - 效果高大上 :) Spider Studio 新版本 (20140109) - 修复浏览器对部分网页不支持的BUG Spider Studio 新版本 (20140108) - 优化设置菜单 / 生成程序集支持版本号 示例 - 数据仓库的妙用 Spider Studio 界面功能布局 C# 脚本代码自动登录淘宝获取用户信息 - Ivan Zou API - 使用数据仓库 - 基础篇 示例 - 如何在ASP.NET中应用Spider Studio生成的DLL? 示例 - 如何在多线程中应用SpiderStudio生成的DLL? 示例 - 如何在Console应用程序中应用SpiderStudio生成的DLL? - Ivan Zou C#中另辟蹊径解决JSON / XML互转的问题 - Ivan Zou Spider Studio 新版本 (x-mas) - 可以引入第三方程序集, 可以将脚本生成为DLL
示例 - 如何在NodeJS中调用SS生成的DLL
Ivan Zou · 2014-02-25 · via 博客园 - Ivan Zou

要想在NodeJS中调用SS生成的DLL, 需要借助EdgeJS. 

EdgeJS: http://tjanczuk.github.io/edge/

如果你还不知道如何在SS中生成DLL, 请查看: Spider Studio 新版本 (x-mas) - 可以引入第三方程序集, 可以将脚本生成为DLL

下面以曾经写过的XML/JSON互转的脚本为例 (C#中另辟蹊径解决JSON / XML互转的问题) 说明如何在NodeJS中应用SS DLL:

1. 安装edgejs

2. 为www.utilities_online.info.XmlJsonConverter.dll编写一个javascript的代理脚本

一共两个方法, Xml2Json & Json2Xml:

var edge = require('edge');

exports.xml2json = edge.func({
    source: function() {/*

        using System.Threading;
        using System.Threading.Tasks;
        using www.utilities_online.info;

        public class Startup
        {
            public async Task<object> Invoke(object input)
            {
                object result = null;
                Thread t = new Thread(new ParameterizedThreadStart((p) => { 
                    using(var proxy = new XmlJsonConverter())
                    {
                        proxy.Init();
                        result = proxy.Xml2Json(p.ToString());
                    }
                } ));
                t.SetApartmentState(ApartmentState.STA);
                t.IsBackground = true;
                t.Start(input);
                while (t.ThreadState != ThreadState.Stopped)
                {
                    Thread.Sleep(100);
                }
                return result;
            }
        }
    */},
    references: [ __dirname + '\\www.utilities_online.info.XmlJsonConverter.dll' ]
});

exports.json2xml = edge.func({
    source: function() {/*

        using System.Threading;
        using System.Threading.Tasks;
        using www.utilities_online.info;

        public class Startup
        {
            public async Task<object> Invoke(object input)
            {
                object result = null;
                Thread t = new Thread(new ParameterizedThreadStart((p) => { 
                    using(var proxy = new XmlJsonConverter())
                    {
                        proxy.Init();
                        result = proxy.Json2Xml(p.ToString());
                    }
                } ));
                t.SetApartmentState(ApartmentState.STA);
                t.IsBackground = true;
                t.Start(input);
                while (t.ThreadState != ThreadState.Stopped)
                {
                    Thread.Sleep(100);
                }
                return result;
            }
        }
    */},
    references: [ __dirname + '\\www.utilities_online.info.XmlJsonConverter.dll' ]
});

3. 编写服务脚本 www.utilities_online.info.XmlJsonConverter.js

var http = require('http');
var xmlJson = require('./www.utilities_online.info.XmlJsonConverter.proxy.js');

var person = { person:{ name:'Mike', age:30 }};

var proxy = http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'application/xml'});
  var xml = xmlJson.json2xml(JSON.stringify(person), true);
  console.log(xml);
  res.end(xml);
}).listen(1338);

4. 运行, 查看效果: