上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 54 下一页
摘要: # import os import requests from bs4 import BeautifulSoup # 登陆, 模仿用户浏览器 r1 = requests.get( # 要爬取的博客圆页面 url='https://zzk.cnblogs.com/s/blogpost?Keywords=blog%3aaronthon%201&pageindex=9', #... 阅读全文
posted @ 2018-04-23 11:09 aaronthon 阅读(132) 评论(0) 推荐(0) 编辑
摘要: # import os import requests from bs4 import BeautifulSoup r1 = requests.get( url='http://jandan.net/', # 浏览器的信息 headers={ 'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleW... 阅读全文
posted @ 2018-04-23 10:11 aaronthon 阅读(153) 评论(0) 推荐(0) 编辑
摘要: import os import requests from bs4 import BeautifulSoup # 登陆, 模仿用户浏览器 r1 = requests.get( # 要爬取的网页 url='https://dig.chouti.com/', # 浏览器的信息 headers={ 'user-agent':'Mozilla/5.0 (... 阅读全文
posted @ 2018-04-22 11:03 aaronthon 阅读(381) 评论(0) 推荐(0) 编辑
摘要: 1. 下载BeautifulSoup和requests 1. 先去https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted下载 Twisted‑18.7.0‑cp36‑cp36m‑win_amd64.whl文件,并保存到一个文件夹中。 2. 打开cmd命 阅读全文
posted @ 2018-04-21 21:00 aaronthon 阅读(128) 评论(0) 推荐(0) 编辑
摘要: import requests import re import json def getPage(url): response=requests.get(url) return response.text def parsePage(s): com=re.compile('<div class=" 阅读全文
posted @ 2018-04-20 18:46 aaronthon 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 1. self表示一个类的实例对象本身。如果用了staticmethod就无视这个self了,就将这个方法当成一个普通的函数使用了。 2. cls表是这个类本身。 3. 更多: 类先调用__new__方法,返回该类的实例对象,这个实例对象就是__init__方法的第一个参数self,即self是__ 阅读全文
posted @ 2018-04-19 19:05 aaronthon 阅读(9180) 评论(4) 推荐(2) 编辑
摘要: 这个的路径是怎么来的,是有一个个的url路由分发过来的 这两个是相等的,若url后面加括号了,那么前面就不用这个装饰器了;反之,若装饰器使用了,那么这个url后面就不要加括号了 eg:其他的views.test这是一个视图函数,而那个url()这个一个大列表,里面全是url,这里面就是所谓的二级分发 阅读全文
posted @ 2018-04-17 15:54 aaronthon 阅读(905) 评论(0) 推荐(0) 编辑
摘要: Django自带的后台管理是Django明显特色之一,可以让我们快速便捷管理数据。后台管理可以在各个app的admin.py文件中进行控制。以下是我最近摸索总结出比较实用的配置。若你有什么比较好的配置,欢迎补充。 一、基本设置 1、应用注册 若要把app应用显示在后台管理中,需要在admin.py中 阅读全文
posted @ 2018-04-16 14:58 aaronthon 阅读(767) 评论(0) 推荐(1) 编辑
摘要: Django中model部分的写法, 参见 unique-together 部分文档。 对应到 MySQL 中的 SQL , 类似如下的语句 阅读全文
posted @ 2018-04-15 19:40 aaronthon 阅读(2922) 评论(0) 推荐(0) 编辑
摘要: isinstance isinstance(object, classinfo) 判断实例是否是这个类或者object是变量 classinfo 是类型(tuple,dict,int,float,bool,complex,str,list,set) 判断变量是否是这个类型 class objA: p 阅读全文
posted @ 2018-04-14 16:33 aaronthon 阅读(1522) 评论(0) 推荐(0) 编辑
上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 54 下一页