css/js(工做中遇到的問題)-6

頁面resize方法

if(document.createEvent) { 
   const event = document.createEvent ("HTMLEvents");
   event.initEvent("resize", true, true); 
   window.dispatchEvent(event); 
} else if(document.createEventObject){ 
   window.fireEvent("onresize"); 
}

前端複製功能總結

在html頁面中展現JSON

css 解決div之間有間隙

font-size: 0;

json字符格式化

JSON.stringify(json, ' ', 4)

避免移動端將數字識別成電話號碼而高亮

<meta name="format-detection" content="telephone=no">

百度搜索接口

const BAIDU_URL = 'http://www.baidu.com.cn/s';
const now_data = parseInt((new Date).getTime() / 1000);
const month_time = 2678400
const thirty_day_age = now_data - month_time;
const keyword = name + ' ' + entity_name + ' ' + job_title;
page = page || 1;

request.get(BAIDU_URL, {
      qs: {
        //關鍵詞
        wd: keyword,
        //時間限制: 一個月
        gpc: `stf=${thirty_day_age},${now_data}|stftype=1`,
        // offset
        pn: page * 10 - 10
      }
}

百度新聞搜索接口

const BAIDU_URL = 'http://news.baidu.com/ns';
const rn = 20
page = page || 1;


request.get(BAIDU_URL, {
      headers: {
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36'
      },
      qs: {
        //0:按時間排序, 1:按焦點排序
        ct: 0,
        tn: 'news',
        //關鍵詞
        word: keyword,
        //每頁新聞數
        rn,
        //offset
        pn: page * rn - rn
      }
    }

支付寶支付接口

相關文章
相關標籤/搜索