小编the*_*ogz的帖子

使用Horseman和PhantomJS下载wav文件会丢失数据质量

我正在使用PhantomJSHorsemanJS从远程服务器下载wav文件.但是,当文件是base64编码并写入新文件时,它会失去质量,使其无法使用.音频在那里,但它的扭曲导致我认为它是一个编码问题.我正在使用节点v5在Ubuntu 14.04上运行

以下是我的脚本可能有任何想法改进base64编码?

var Horseman = require('node-horseman');
var horseman = new Horseman({cookiesFile:'./cookiejar'});
var fs = require('fs');

horseman.on("urlChanged", function(url){
  console.log(url);
});

horseman.on('consoleMessage', function( msg ){
  console.log(msg);
});

horseman
  .userAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
  .open('https://remoteserver.com/audo.aspx?guid=01439900-5361-4828-ad0e-945b56e9fe51')
  .waitForNextPage()
  .type('input[name="password"]', process.env.PASS)
  .type('input[name="username"]', process.env.UN)
  .click("button:contains('Login')")
  .waitForNextPage()
  .evaluate(function(){
    var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    function base64encode(str) {
        var out, i, len;
        var c1, c2, c3;

        len = str.length;
        i = 0;
        out = "";
        while(i < len) {
        c1 = …
Run Code Online (Sandbox Code Playgroud)

javascript audio base64 node.js phantomjs

11
推荐指数
1
解决办法
649
查看次数

如何解析字符串并在Apex代码中返回枚举值?

我想在我的Apex代码中使用Enum值,因为我们在使用外部服务时有一些严格的类型,但是当我从外部服务获得响应时,我正在努力将Enum值的String表示转换回Enum所以它可以在我的代码中使用.

要在C#中执行此操作,我会这样做:

DayOfWeek wednesday = 
      (DayOfWeek)Enum.Parse(typeof(DayOfWeek), "Wednesday");
Run Code Online (Sandbox Code Playgroud)

但在Apex代码中我找不到办法做到这一点.有人有解决方案吗?

salesforce apex-code

5
推荐指数
1
解决办法
4030
查看次数

标签 统计

apex-code ×1

audio ×1

base64 ×1

javascript ×1

node.js ×1

phantomjs ×1

salesforce ×1