url

Vue.js--axios详解

被刻印的时光 ゝ 提交于 2020-02-04 00:43:30
axios axios是一个基于Promise,同时支持浏览器端和Node.js的HTTP库,常用于Ajax请求。 安装axios npm install axios --save axios的请求方式 axios(config) axios.request(config) axios.get(url [, config]) axios.delete(url [, config]) axios.head(url [, config]) axios.post(url [, data [,config]]) axios.put(url [, data [, config]]) axios.patch(url [, data [, config]]) 直接发起GET请求: import axios from 'axios' //1. 没有请求参数 axios . get ( 'http://123.207.32.32:8000/home/multidata' ) . then ( res => { console . log ( res ) ; } ) . catch ( err => { console . log ( err ) ; } ) //2.有参数 axios . get ( 'http://123.207.32.32:8000/home/data?type=sell

Axios 封装拦截

折月煮酒 提交于 2020-02-04 00:17:37
一、axios的封装 在vue项目中,和后台交互获取数据这块,我们通常使用的是axios库,它是基于promise的http库,可运行在浏览器端和node.js中。他有很多优秀的特性,例如拦截请求和响应、取消请求、转换json、客户端防御cSRF等。所以我们的尤大大也是果断放弃了对其官方库vue-resource的维护,直接推荐我们使用axios库。 安装 npm install axios; // 安装axios 引入 一般我会在项目的src目录中,新建一个request文件夹,然后在里面新建一个utils.js和一个api.js文件。http.js文件用来封装我们的axios,api.js用来统一管理我们的接口。 环境的切换 我们的项目环境可能有开发环境、测试环境和生产环境。我们通过node的环境变量来匹配我们的默认的接口url前缀。 // 环境的切换 if (process.env.NODE_ENV == 'development') { axios.defaults.baseURL = 'https://www.baidu.com';} else if (process.env.NODE_ENV == 'debug') { axios.defaults.baseURL = 'https://www.ceshi.com'; } else if (process.env

C#QQ空间爬虫 并POST批量操作点赞评论回复等 关键参数获得qzonetoken g_tk

丶灬走出姿态 提交于 2020-02-03 17:35:59
软件下载 : 链接: https://pan.baidu.com/s/1IuLs-C7XQVlI42gdS4p7yQ 提取码: 5vgt (因QQ空间升级,目前只能批量点赞。需IE11) 技术分析:先看一个范例 这是我手工评论别人BBBBBB的抓包。 我想模拟POST发送,就要得到上面的所有参数。其它的直接可以得到,主要以下两个参数 1.g_tk 点发表,跟踪js在 https://qzonestyle.gtimg.cn/ac/qzone/qzfl/qzfl_v8_2.1.65.js 的84行 使用js在线格式化工具 https://tool.oschina.net/codeformat/js/ ,搜上面的位置xhr.send(transdata(data))定位到4776行。 找到xhr.open(opt.method, url + (url.indexOf("?") > -1 ? "&": "?") + "g_tk=" + QZFL.pluginsDefine.getACSRFToken(url), true); 是通过url得到的。再看看url url我复制出来 (数据部分我改了一点,规避隐私) https://user.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/cgi-bin/feeds/cgi_get_feeds_count

解决css引用字体跨域问题

二次信任 提交于 2020-02-03 16:20:39
解决css引用字体跨域问题 公司的vue项目用的是外部的免费cdn库,导致放假期间cdn挂了所有网页都打不开了,所以把外部的js,css都引入到了自己的cdn服务器,但有些UI库的css是引入本地的字体图标,导致引入本地css后产生了跨域 问题核心 @font - face { font - family : my - icon ; src : url ( . . / font / iconfont . eot ? v = 240 ) ; src : url ( . . / font / iconfont . eot ? v = 240 #iefix ) format ( 'embedded-opentype' ) , url ( . . / font / iconfont . svg ? v = 240 #iconfont ) format ( 'svg' ) , url ( . . / font / iconfont . woff ? v = 240 ) format ( 'woff' ) , url ( . . / font / iconfont . ttf ? v = 240 ) format ( 'truetype' ) } 解决方案 字体转base64编码网址: https://transfonter.org/ 将图标库转成baes64 使用

Node.js---起步

徘徊边缘 提交于 2020-02-03 15:35:37
1.下载--安装 2.创建js文件 var http = require('http'); var url=require('url'); //引入url 模块,帮助解析 var querystring=require('querystring');// 引入 querystring 库,也是帮助解析用的 function service(req,response){ //获取返回的url对象的query属性值 var arg = url.parse(req.url).query; //将arg参数字符串反序列化为一个对象 var params = querystring.parse(arg); //请求的方式 console.log("method - " + req.method); //请求的url console.log("url - " + req.url); //获取参数id console.log("id- " + params.id); //头部 response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello Node.js'); } var server = http.createServer(service); //端口号 server.listen(8088); 3

《第9章 使用HTTP协议访问网络》 总结2 使用HttpURLConnection和OkHttp

为君一笑 提交于 2020-02-03 14:23:50
HttpURLConnection的使用 获取HttpURLConnection对象实例 new一个URL 对象 ,传入目标的网络地址: URL url = new URL("https://www.baidu.com"); 调用URL对象的 openConnection() 方法: HttpURLConnection connection = (HttpURLConnection)url.openConnection(); 设置HTTP请求使用的方法: GET 和 POST connection.setRequestMethod(“GET”); connection.setRequestMethod(“POST”); DataOutputStream out= new DataOutputStream(connecton.getOutputStrem()); out.write(“username=admin&password=123456”); 接下来可以进行一个自由的定制,比如连接超时,读取超时的毫秒数,以及服务器希望得到的一些消息头等,例如: connection.setConnectionTimeout(8000); connection.setReadTimeout(8000); 获取服务器的返回流: InputStream in = connection

Regex to match specific path with specific query param

主宰稳场 提交于 2020-02-03 11:07:07
问题 I'm struggling with creating regex to match URL path with query param that could be in any place. For example URLs could be: /page?foo=bar&target=1&test=1 <- should match /page?target=1&test=2 <- should match /page/nested?foo=bar&target=1&test=1 <- should NOT match /page/nested?target=1&test=2 <- should NOT match /another-page?foo=bar&target=1&test=1 <- should NOT match /another-page?target=1&test=2 <- should NOT match where I need to target param target specifically on /page This regex works

Regex to match specific path with specific query param

两盒软妹~` 提交于 2020-02-03 11:04:14
问题 I'm struggling with creating regex to match URL path with query param that could be in any place. For example URLs could be: /page?foo=bar&target=1&test=1 <- should match /page?target=1&test=2 <- should match /page/nested?foo=bar&target=1&test=1 <- should NOT match /page/nested?target=1&test=2 <- should NOT match /another-page?foo=bar&target=1&test=1 <- should NOT match /another-page?target=1&test=2 <- should NOT match where I need to target param target specifically on /page This regex works

Clickable link in tooltip of Highcharts

南笙酒味 提交于 2020-02-03 09:45:49
问题 I have tooltips having a list of data in it. I want each data to be a link which redirects to the page for that particular data. Now the problem with Highcharts tooltip is that it changes with respective to the x-axis. As soon as x-axis changes, the tooltip changes to the respective component on the x-axis. So in case i get my tooltip working with links, as soon as i move to click the link, the tooltip changes. To tackle this I figured out a way to fix the tooltip as soon as you click on the

Clickable link in tooltip of Highcharts

好久不见. 提交于 2020-02-03 09:45:30
问题 I have tooltips having a list of data in it. I want each data to be a link which redirects to the page for that particular data. Now the problem with Highcharts tooltip is that it changes with respective to the x-axis. As soon as x-axis changes, the tooltip changes to the respective component on the x-axis. So in case i get my tooltip working with links, as soon as i move to click the link, the tooltip changes. To tackle this I figured out a way to fix the tooltip as soon as you click on the