response

BBS+Blog项目代码

好久不见. 提交于 2020-01-31 05:00:43
项目目录结构: 1 cnblog/ 2 |-- blog/(APP) 3 |-- migrations(其中文件略) 4 |-- templatetags/ 5 |-- my_tags.py 6 |-- utils/ 7 |-- myForms.py 8 |-- validCode.py 9 |-- admin.py 10 |-- apps.py 11 |-- models.py 12 |-- test.py 13 |-- views.py 14 15 |-- cnblog/ 16 |-- settings.py 17 |-- urls.py 18 |-- wsgi.py 19 20 |-- media/ 21 |-- add_article_img/ 22 |-- (由用户上传) 23 |-- avatars/ 24 |-- default.jpg 25 |-- (由用户上传) 26 27 |-- static/ 28 |-- blog/ 29 |-- bs/(引入的bootstrap文件夹) 30 |-- css/ 31 |-- article_detail.css 32 |-- backend.css 33 |-- home_site.css 34 |-- img/ 35 |-- default.jpg 36 |-- downdown.gif 37 |-- icon_form

1. 爬虫初体验

限于喜欢 提交于 2020-01-31 04:19:43
1. 爬虫初体验 步骤 体验爬虫 requests.get() Response对象的常用属性 爬虫伦理 步骤 第0步:获取数据。爬虫程序会根据我们提供的网址,向服务器发起请求,然后返回数据。 第1步:解析数据。爬虫程序会把服务器返回的数据解析成我们能读懂的格式。 第2步:提取数据。爬虫程序再从中提取出我们需要的数据。 第3步:储存数据。爬虫程序把这些有用的数据保存起来,便于你日后的使用和分析。 这就是爬虫的工作原理啦,无论之后的学习内容怎样变化,其核心都是爬虫原理。 下面,我们快速浏览一下整个关卡的学习大纲。大纲展示了我们将如何逐步学习和掌握爬虫这项技能,了解即可。 体验爬虫 这一部分的任务就是学会爬虫的第0步:获取数据。 我们将会利用一个强大的库——requests来获取数据。 在学习系统里,已经帮你预装好requests库。如果你希望在电脑上安装,方法是:在Mac电脑里打开终端软件(terminal),输入pip3 install requests,然后点击enter即可;Windows电脑里叫命令提示符(cmd),输入pip install requests 即可。 requests库可以帮我们下载网页源代码、文本、图片,甚至是音频。其实,“下载”本质上是向服务器发送请求并得到响应。 先来看requests.get()方法。 requests.get() requests

vue+axios网络应用

自闭症网瘾萝莉.ら 提交于 2020-01-30 22:11:53
1.axios axios 必须先导入才可以使用 使用 get 和 post 方法可以发送对应请求 then 方法中的回调函数会在请求成功或失败时触发 网络请求库: < input type = "button" value = "get请求" class = "get" > < input type = "button" value = "post请求" class = "post" > < ! -- < script src = "https://cdn.jsdelivr.net/npm/vue/dist/vue.js" > < / script > -- > < script src = "https://unpkg.com/axios/dist/axios.min.js" > < / script > < script > document . querySelector ( ".get" ) . onclick = function ( ) { axios . get ( "https://autumnfish.cn/api/joke/list?num=3" ) . then ( function ( response ) { console . log ( response ) ; } , function ( err ) { console . log ( err )

requests模块

和自甴很熟 提交于 2020-01-30 21:08:59
安装 pip install requests pip install -i https://pypi.doubanio.com/simple/ requests requests.request() 请求接受的参数 requests.request(method, url,** kwargs)类能够构造一个请求,支持不同的请求方式 import requests response = requests.request(method='get', url='https://www.baidu.com') print(response.status_code) request类中几个参数: method:请求方式。 url:请求URL。 **kwargs: params:字典或者字节序列,作为参数增加到url中,使用这个参数可以把一些键值对以 k1=v1&k2=v2 的模式增加到url中,get请求中用的较多。 data:字典、字节序列或者文件对象,重点作为向服务器提供或提交资源,作为请求的请求体,与params不同放在url上不同。它也可以接受一个字符串对象。 json:json格式的数据,可以向服务器提交json类型的数据。 headers:字典,定义请求的请求头,比如可以headers字典定义user agent。 cookies:字典或者CookieJar。 auth:元组

【转】ASP.NET Core 2.0中的HttpContext

被刻印的时光 ゝ 提交于 2020-01-30 20:43:49
  ASP.NET Core 2.0中的HttpContext相较于ASP.NET Framework有一些变化,这边列出一些之间的区别。   在ASP.NET Framework中的 System.Web.HttpContext 对应 ASP.NET Core 2.0中的 Microsoft.AspNetCore.Http.HttpContext。 HttpContext   HttpContext.Items转换成:  IDictionary<object, object> items = httpContext.Items;   请求的唯一的ID: string requestId = httpContext.TraceIdentifier; HttpContext.Request   HttpContext.Request.HttpMethod 转换成: string httpMethod = httpContext.Request.Method;   HttpContext.Request.QueryString 转换成: IQueryCollection queryParameters = httpContext.Request.Query; // If no query parameter "key" used, values will have 0 items //

asp.net文件下载方法...

一个人想着一个人 提交于 2020-01-30 19:24:38
TransmitFile实现下载 protected void Button1_Click(object sender, EventArgs e) { /* 微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite 下载超过400mb的文件时导致Aspnet_wp.exe进程回收而无法成功下载的问题。 代码如下: */ Response.ContentType = "application/x-zip-compressed"; Response.AddHeader("Content-Disposition", "attachment;filename=z.zip"); string filename = Server.MapPath("DownLoad/z.zip"); Response.TransmitFile(filename); } //WriteFile实现下载 protected void Button2_Click(object sender, EventArgs e) { /* using System.IO; */ string fileName = "asd.txt";//客户端保存的文件名 string filePath = Server.MapPath("DownLoad/aaa.txt");/

springboot集成拦截器

六月ゝ 毕业季﹏ 提交于 2020-01-30 18:24:17
一.首先对HandlerInterceptor进行封装,封装为MappingInterceptor.封装的方法里添加拦截器起作用的路径addPathPatterns(),及需要排除路径的方法excludePathPatterns() public interface MappingInterceptor extends HandlerInterceptor { String[] addPathPatterns(); String[] excludePathPatterns(); int order(); } 二.写拦截器,拦截器实现封装好的MappingInterceptor,同时在拦截器上添加@Component,作用是将该拦截器注入到容器中以方便通过@Autowired实现实例注入. @Component public class CrossOriginInterceptor implements MappingInterceptor { private static final Logger logger= LoggerFactory.getLogger(CrossOriginInterceptor.class); @Override public String[] addPathPatterns() { return new String[]{"/**"}; }

Cannot forward after response has been committed问题解决及分析

丶灬走出姿态 提交于 2020-01-30 12:47:22
Cannot forward after response has been committed问题解决及分析 Cannot forward after response has been committed 中文意思就是已经有提交了,不能够再次转向了,然后根据JSP标签中设置的错误页面又回到了登陆页面 java.lang.IllegalStateException: Cannot forward after response has been committed 解决方法: RequestDispatcher rd = sc.getRequestDispatcher("/customermanage.jsp"); rd.forward(request,response); return; //这里要加个return 这里为什么要加return 是因为: 这个是错误是由于response多次提交或者是由于有页面显示后仍然含请求转向产生的,就是说程序在return之前就已经执行了跳转或者执行过response,之后遇到return的话,程序想再次执行跳转,也就是重定向,这时功能也许会实现了,但是控制台会报错,所以控制好跳转是很重要的,我现在的解决办法还是加return null 来源: CSDN 作者: zhupengqq1 链接: https://blog.csdn.net

前端必备工具类

守給你的承諾、 提交于 2020-01-30 09:58:30
Http请求工具 注意,大部分情况下,我们后端返回的数据格式都是类似 { "code" : 0 , "data" : { } , "msg" : "" } 所以我们在请求工具中可以统一检查 code,如果返回正确则只返回 data 中的数据 import axios from 'axios' ; // 创建axios实例 var instance = axios . create ( { timeout : 120000 , headers : { 'X-Requested-With' : 'XMLHttpRequest' } } ) ; axios . defaults . withCredentials = true ; // 添加响应拦截器 axios . interceptors . response . use ( function ( response ) { return response ; } , function ( error ) { // todo 这里可以统一拦截非200状态响应 return Promise . reject ( error ) ; } ) ; /** * 发送 GET 请求,当 code 的值等于期望的值时解析 response.data.data * * 否则拒绝,并传递 data.message 或 data.msg * *

【爬虫学习笔记day07】1.5. Requests深入+基本POST请求(data参数)+代理(proxies参数)+私密代理验证(特定格式) 和 Web客户端验证(auth 参数)+Cookies

▼魔方 西西 提交于 2020-01-30 02:54:12
文章目录 1.5. Requests深入 基本POST请求(data参数) 1. 最基本post方法 2. 传入data数据 代理(proxies参数) 私密代理验证(特定格式) 和 Web客户端验证(auth 参数) 私密代理 web客户端验证 Cookies 和 Sission Cookies session 实现人人网登录 处理HTTPS请求 SSL证书验证 1.5. Requests深入 基本POST请求(data参数) 1. 最基本post方法 response = requests . post ( "http://www.baidu.com/" , data = data ) 2. 传入data数据 对于 POST 请求来说,我们一般需要为它增加一些参数。那么最基本的传参方法可以利用 data 这个参数。 import requests formdata = { "type" : "AUTO" , "i" : "i love python" , "doctype" : "json" , "xmlVersion" : "1.8" , "keyfrom" : "fanyi.web" , "ue" : "UTF-8" , "action" : "FY_BY_ENTER" , "typoResult" : "true" } url = "http://fanyi.youdao