上一页 1 2 3 4 5 6 7 ··· 9 下一页
摘要: 高性能相关 在编写爬虫时,性能的消耗主要在IO请求中,当单进程单线程模式下请求URL时必然会引起等待,从而使得请求整体变慢。 1 import requests 2 3 def fetch_async(url): 4 response = requests.get(url) 5 return res 阅读全文
posted @ 2017-08-30 16:07 ForeverPine 阅读(542) 评论(0) 推荐(0) 编辑
摘要: requests Python标准库中提供了:urllib、urllib2、httplib等模块以供Http请求,但是,它的 API 太渣了。它是为另一个时代、另一个互联网所创建的。它需要巨量的工作,甚至包括各种方法覆盖,来完成最简单的任务。 Requests 是使用 Apache2 License 阅读全文
posted @ 2017-08-28 19:02 ForeverPine 阅读(2245) 评论(2) 推荐(1) 编辑
摘要: 一、原生AJAX,jQuery Ajax,“伪”AJAX,JSONP 1. 浏览器访问 2. urls from django.conf.urls import url from django.contrib import admin from app01 import views urlpatte 阅读全文
posted @ 2017-07-06 17:41 ForeverPine 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 一、文件上传 1. 浏览器访问 2. urls 3. views 1 from django.shortcuts import render,redirect,HttpResponse 2 from app01 import models 3 from django.forms import For 阅读全文
posted @ 2017-07-06 17:02 ForeverPine 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 一、Form提交验证与Ajax提交验证的运用实例 Form表单提交时会刷新页面,输入失败时,输入框内内容也会随之刷新不能保留;而Ajax提交是在后台偷偷提交,不会刷新页面,因此也就可以保留页面输入框内的内容。 1. 浏览器访问 2. urls 3. views from django.shortcu 阅读全文
posted @ 2017-07-06 16:54 ForeverPine 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 一、Form提交验证之(学生表、老师表、班级表)的添加和编辑实现案例 1. 浏览器访问 2. models 1 from django.db import models 2 3 class Classes(models.Model): 4 title = models.CharField(max_l 阅读全文
posted @ 2017-07-06 16:54 ForeverPine 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容 一、小试牛刀 1、创建Form类 1 from django.forms import Form 2 from django.forms impo 阅读全文
posted @ 2017-07-03 15:00 ForeverPine 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 一、cbv a.基本演示 1 urlpatterns = [ 2 3 url(r'^login.html$', views.Login.as_view()), 4 ] 1 from django.views import View 2 3 class Login(View): 4 """ 5 get 阅读全文
posted @ 2017-07-03 08:45 ForeverPine 阅读(465) 评论(0) 推荐(0) 编辑
摘要: 一、Model 到目前为止,当我们的程序涉及到数据库相关操作时,我们一般都会这么搞: 创建数据库,设计表结构和字段 使用 MySQLdb 来连接数据库,并编写数据访问层代码 业务逻辑层去调用数据访问层执行数据库操作 1 import MySQLdb 2 3 def GetList(sql): 4 d 阅读全文
posted @ 2017-06-28 16:05 ForeverPine 阅读(502) 评论(0) 推荐(0) 编辑
摘要: 一、Web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端。 上述通过socket来实现了其本质,而对于真实开发中的python web程序来说,一般会分为两部分:服务器程序和应用程序。服务器程序负责对socket服务器进行封 阅读全文
posted @ 2017-06-15 19:20 ForeverPine 阅读(269) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 9 下一页
TOP