How to use the urllib.create function in urllib

To help you get started, we’ve selected a few urllib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github micooz / wallpaper / lib / sources / bing.js View on Github external
'use strict';

var http = require('urllib').create();
var shell = require('shelljs');
var path = require('path');
var fs = require('fs');
var logger = require('../utils/logger');

var resource = {
  url: 'http://cn.bing.com/HPImageArchive.aspx',
  params: {
    format: 'js', // return json
    idx: 0, // 0 - today, 1 - yesterday, 2 - the day before yesterday ...
    n: 1 // how many images in the result
  }
};

exports.first = function (cb) {
  // 1. get image url
github micooz / wallpaper / lib / sources / your.js View on Github external
'use strict';

var http = require('urllib').create();
var shell = require('shelljs');
var path = require('path');
var fs = require('fs');
var logger = require('../utils/logger.js');

exports.first = function (cb) {
  // implement your logic here, cb need a image path based on filesystem.
  // Then specify --source=your in command line, and have fun.
  // 
  // Also I would appreciate it if you could share your source at:
  //   https://github.com/micooz/wallpaper/pulls
  // 
  
  
  // cb(file);
};
github micooz / wallpaper / lib / sources / uri.js View on Github external
'use strict';

var http = require('urllib').create();
var shell = require('shelljs');
var path = require('path');
var fs = require('fs');
var logger = require('../utils/logger.js');

var _uri = '';

function _first(cb) {
  logger.info('downloading from: ' + _uri);

  http.request(_uri, {}, function (err, data) {
    var file = path.join(shell.tempdir(), 'tmp.jpg');
    fs.writeFile(file, data, function (err) {
      if (err) {
        logger.fatal('cannot save image to: ' + file);
        process.exit(-1);
github eggjs / egg-init / lib / init_command.js View on Github external
constructor(options) {
    options = options || {};
    this.name = options.name || 'egg-init';
    this.configName = options.configName || 'egg-init-config';
    this.pkgInfo = options.pkgInfo || require('../package.json');
    this.needUpdate = options.needUpdate !== false;
    this.httpClient = urllib.create();

    this.inquirer = inquirer;
    this.fileMapping = {
      gitignore: '.gitignore',
      _gitignore: '.gitignore',
      '_.gitignore': '.gitignore',
      '_package.json': 'package.json',
      '_.eslintignore': '.eslintignore',
      '_.npmignore': '.npmignore',
    };
  }
github Luncher / alipay / src / index.js View on Github external
makeRequest (params, options = {}) {
    const httpclient = urllib.create()
    return httpclient.request(GETWAY, Object.assign({}, {
      data: params,
      dataType: 'json',      
      dataAsQueryString: true
    }, options))
    .then(resp => this.makeResponse(resp.data))
  }
github cnpm / cnpmjs.org / common / urllib.js View on Github external
});
  } else {
    throw new TypeError('httpProxy format error: ' + config.httpProxy);
  }
} else {
  httpAgent = new HttpAgent({
    timeout: 0,
    keepAliveTimeout: 15000
  });
  httpsAgent = new HttpsAgent({
    timeout: 0,
    keepAliveTimeout: 15000
  });
}

var client = urllib.create({
  agent: httpAgent,
  httpsAgent: httpsAgent
});

module.exports = client;
module.exports.USER_AGENT = urllib.USER_AGENT;

urllib

Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. Base undici fetch API.

MIT
Latest version published 12 days ago

Package Health Score

86 / 100
Full package analysis