zoukankan      html  css  js  c++  java
  • async

    var fs = require('fs');
    var queryString = require("querystring");
    var fetch = require('node-fetch');
    
    var list = fs.readFileSync("title.sql.txt","utf-8");  
    list = list.split("
    ");
    
    async function apiPost( text ){
        var formData = {
            text : text , 
            types : 'head' , 
            lens : 1 , 
            level : 6 
        };
        formData = queryString.stringify(formData);
        var opts = {
            method:"POST",  
            body:formData, 
           headers: {
             'Accept': 'application/json',
             'Content-Type': 'application/json'
          }
        }
        let ret =  await fetch('http://60.205.105.147/nlpir/',opts)
            .then((res) => {
                return res.json();
            })
            .then((json) => {
                return json ;
            })
            .catch((error) => {
                console.log(error);
                return {error:1};
            }); 
        return ret ;
    }
    
    async function run(){
        var text = {};
        for(i=0;i<200;i++){
            title = list.shift();
            text[ i ] = title ;
            i++;
        }
        var m = await apiPost(JSON.stringify(text));
        console.log(m.head,m.limitTime,m.msg);
    }
    
    run();
    

      

  • 相关阅读:
    SQL——BETWEEN操作符
    SQL——IN操作符
    SQL——LIKE操作符
    SQL——ORDER BY关键字
    SQL——AND、OR运算符
    顺序执行
    流程控制
    集合类型
    字典类型
    字典 in 操作符
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9005220.html
Copyright © 2011-2022 走看看