07 2023 档案
摘要:[https://www.django-rest-framework.org/api-guide/pagination/](https://www.django-rest-framework.org/api-guide/pagination/) DRF给我们提供了几个分页器类,比较常用的2个是: -
阅读全文
摘要:[https://www.django-rest-framework.org/api-guide/filtering](https://www.django-rest-framework.org/api-guide/filtering) 一般情况下,我们可以重写DRF视图类的`get_queryse
阅读全文
摘要:[https://www.django-rest-framework.org/api-guide/throttling/](https://www.django-rest-framework.org/api-guide/throttling/) 限制、控制客户端可以向 API 发出的请求的速率。 #
阅读全文
摘要:有时候前端需要各种各样的过滤查询,如果自己写多少有点麻烦和冗余。使用django-filter就可以很好的解决这个问题。 django-filter可以用在django上, 也与配合drf一起使用。 主要区别在于drf要集成的FilterSet和django的不是同一个,别的都差不多。 下面展示配合
阅读全文
摘要:**官方文档:** [https://apscheduler.readthedocs.io](https://apscheduler.readthedocs.io) # APScheduler的4个组件 - triggers【触发器】 - job stores【任务存储】 - executors【执
阅读全文
摘要:[https://docs.sqlalchemy.org/en/20/tutorial/data.html](https://docs.sqlalchemy.org/en/20/tutorial/data.html) # 新旧版语法的说明 在2.x的SQLALchemy中,查询语法为: `db.se
阅读全文
摘要:1、首先安装elasticsearch包 pip install elasticsearch (一般会包含新旧版本,如果想要特定的版本,比如5.x 可以在后面加5数字) ```Python """ 1、首先安装elasticsearch包 pip install elasticsearch (一般会
阅读全文
摘要:这可是我几年前的杰作笔记呀.....当初手写计算都会,现在忘光光.... ## 物理硬盘Block的概念和作用 ```Bash 硬盘底层一次IO就是读、写一次扇区,一个扇区默认是512Byte。 读写大量文件如果以扇区为单位会很慢、性能不好, 所以出现了逻辑块的概念(logic block),也就是
阅读全文
摘要:# 物理磁盘名次和其作用 ## 盘片:disk ```Bash 盘片上下都有磁头。 ``` ## 磁盘面: ```Bash 盘片有上下两面,每一面叫磁盘面 ``` ## 磁头:heads ```Bash 每个磁头负责一个磁盘面,负责读取数据、将数据写入磁道。 磁头都是固定在机械臂上(机械臂就是磁头臂
阅读全文
摘要:[https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search.html) [ht
阅读全文
摘要:文档就是相当于每条记录。 **每个文档(数据记录行)都有几个元数据,分别是**: - _index,表示该文档是那个索引中的。 - _type,表示文档的类型 - _id,文档的唯一ID编号 - _score,相关性分数。 # 添加文档(添加数据) ```JSON POST /库名/类型名[/id]
阅读全文
摘要:**创建别名:** [https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-aliases.html](https://www.elastic.co/guide/en/elasticsearch/reference/6
阅读全文
摘要:[https://www.elastic.co/guide/en/elasticsearch/reference/6.8/mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/mapping.html) 7
阅读全文
摘要:官方文档:[https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices.ht
阅读全文
摘要:[https://github.com/medcl/elasticsearch-analysis-ik](https://github.com/medcl/elasticsearch-analysis-ik) **分词测试:** [https://www.elastic.co/guide/en/el
阅读全文
摘要:RMAN备份数据库物理文件到备份集(backupset)中。在创建备份集时,仅备份已经使用的数据库(不备份空闲的数据块),而且还可以采用压缩功能。 RMAN恢复时指当数据库出现介质失败时,使用RMAN命令转储(restore)并恢复(recover)数据库的方法,使用restore命令进行备份文件的
阅读全文
摘要:数据字典是存放整个数据库实例重要信息的一组**表**,这些数据字典大部分都是SYS用户所有。 # 数据字典的构成 Oracle数据字典名称由前缀和后缀组成,使用下画线“_”连接。其代表的含义如下。 - USER_ :记录用户的对象信息。 - ALL_ :记录用户的对象信息及被授权访问的对象信息。 -
阅读全文
摘要:# 密码文件 oracle用于验证sysdba权限的二进制文件。 # 警告日志文件 警告日志文件是用来记录oracle数据库系统在运行期间的各种信息: oracle实例打开和关闭、建立表空间、增加数据文件等记录。 警告日志文件名一般为:alert_.log。 ```SQL [oracle@swq ~
阅读全文
摘要:spfile:server parameter file。 spfile只能通过OEM(oracle enterprise manager)软件或者alter system命令进行修改。 spfile是一个二进制文件,用来记录oracle实例的基本参数信息: - 实例名 - 控制文件路径 - 进程等
阅读全文
摘要:# 日志文件 oracle日志文件分为两种: - 重做日志文件(redo),或者称为“在线重做日志” - 归档日志文件(arch),或者称为“归档重做日志” ## 在线重做日志文件 全称:Online Redo Log File。 **用来记录数据发生事务transaction的信息以及Oracle
阅读全文
摘要:# 控制文件的作用 - 控制文件是一个存储Oracle实例信息、数据文件和日志文件信息的内部二进制文件,如果启用了RMAN备份,还会存储RMAN备份的信息。 - 控制文件一般在Oracle系统安装时自动创建,控制文件所存放的路径由服务器参数文件SPFILEsid.ora的control_files参
阅读全文
摘要:# 表空间:tablespace **表空间就是:**存放数据库表、索引、等等对象的**逻辑空间**。 oracle数据在安装并创建实例后,默认会自动创建多个表空间。 ## ORACL默认表空间 ### SYSTEM表空间 - 存放oracle内部表和数据字典(各种视图、表),如表名、列名、用户名等
阅读全文
摘要:# oracle数据块的基本概念 物理磁盘有物理磁盘的block概念 文件系统也有文件系统block概念 对于磁盘block和文件系统block,可以看回原来的笔记:磁盘专题 而oracle也有block概念,实际上就是基于文件系统block下基于自己定义的概念。 oracle在创建表空间、数据文件
阅读全文
摘要:```SQL LSNRCTL> help The following operations are available An asterisk (*) denotes a modifier or extended command: start stop status services version
阅读全文
摘要:# startup不同参数作用 ## startup nomount 非安装启动,以这种方式启动可执行: 1、重建控制文件、 2、重建数据库读取init.ora文件、 3、启动实例,即启动SGA和后台进程,需要init.ora文件。 ## startup mount 安装启动,以这种方式启动可执行:
阅读全文
摘要:oracle实例、oracle数据库、oracle服务器,这三个术语容易混淆。 # oracle实例 实例是一个非固定的、基于内存基本进程和内存接口生成。当oracle服务器关闭后,实例也就消失。 # oracle数据库 指定的是固定的、基于磁盘的数据文件(datafile)、控制文件(contro
阅读全文
摘要:# 前期准备 ## 关闭selinux ```Bash # 永久关闭,防止重启服务器后又开了。 vim /etc/selinux/config # 临时关闭 setenforce 0 ``` ## 关闭防火墙(不建议,后期建议直接放开相关端口即可) ```Bash systemctl disable
阅读全文
摘要:# 搭建实例 先复制2份解压后的完整目录,将里面的data和log删除. ```Bash elasticsearch-6.8.23-node2 elasticsearch-6.8.23-node3 ``` 修改3个实例的配置文件:(只列出一份,其他的改一下节点名和监听端口、节点内部通信端口就可以了)
阅读全文
摘要:# 快照备份 备份和还原的前提:在配置文件elasticsearch.yml中设置path.repo ```YAML path.repo: ["D:\\elasticsearch-6.8.23\\elasticsearch-6.8.23\\snapshot_data"] ``` ## 创建快照仓库
阅读全文
摘要:RDB:数据库 → 表(列) → 行 Mongo:数据库 → 集合 → 文档 SQL和Mongodb的关系映射表(里面还有一些增删改查等等操作与SQL的对应的语句): [https://www.mongodb.com/docs/manual/reference/sql-comparison/](ht
阅读全文
摘要:使得mongodb具备自动故障转移、高可用、读写分离。 副本集默认情况下读写都只是通过主库,副节点只是备份数据而已,但是可以设置副节点允许读操作,这样就可以做成读写分离。 使用pymongo的时候也可以设置,还可以动态设置库、集合的readPreference。详细的后面再写。。。 如果主节点不可用
阅读全文
摘要:## 读写分离 默认情况下,MongoClient 实例将查询发送到副本集的主要成员。 要使用副节点作为查询,以实现读写分离,我们必须更改读取首选项: 读取首选项在模块`pymongo.ReadPreference`下: - PRIMARY: 从主节点中读取(默认) - PRIMARY_PREFER
阅读全文
摘要:[https://pymongo.readthedocs.io/en/stable/examples/high_availability.html#](https://pymongo.readthedocs.io/en/stable/examples/high_availability.html#)
阅读全文
摘要:使用pymongo,具体可以参考官方文档: 语法上基本和原生mongodb是一样的,所以非常容易入手... [https://pymongo.readthedocs.io/en/stable/tutorial.html](https://pymongo.readthedocs.io/en/stabl
阅读全文
摘要:命令参考:[https://github.com/scrapy/scrapyd-client](https://github.com/scrapy/scrapyd-client) [https://scrapyd.readthedocs.io](https://scrapyd.readthedocs
阅读全文
摘要:scrapy本身是自带支持HTTP2的爬取: [https://docs.scrapy.org/en/latest/topics/settings.html?highlight=H2DownloadHandler#download-handlers-base](https://docs.scrapy
阅读全文
摘要:**高级方法:** **一般方法:** 运行爬虫时使用-a传递参数 ```Bash scrapy crawl 爬虫名 -a key=values ``` 然后在爬虫类的__init__魔法方法中获取kwargs ```Python class Bang123Spider(RedisCrawlSpid
阅读全文
摘要:settings.py中设置配置项 ```Python MONGODB_HOST = "127.0.0.1" MONGODB_PORT = 27017 MONGODB_DB_NAME = "bang123" ``` pipelines.py: ```Python from scrapy.pipeli
阅读全文
摘要:scrapy特性就是效率高,异步,如果非要集成selenium实际上意义不是特别大....因为selenium慢.... 案例:淘宝首页推荐商品的标题获取 爬虫类 toabao.py ```Python import scrapy from scrapy.http import HtmlRespon
阅读全文
摘要:安装包 ```Python pip install -U scrapy-redis ``` settings.py ```Python ##### Scrapy-Redis ##### ### Scrapy指定Redis 配置 ### # 其他默认配置在scrapy_redis.default.py
阅读全文
摘要:参考官方文档:[https://docs.scrapy.org/en/latest/topics/jobs.html?highlight=JOBDIR#jobs-pausing-and-resuming-crawls](https://docs.scrapy.org/en/latest/topics
阅读全文
摘要:CrawlSpider类型的爬虫会根据指定的rules规则自动找到url比自动爬取。 优点:适合整站爬取,自动翻页爬取 缺点:比较难以通过meta传参,只适合一个页面就能拿完数据的。 ```Python import scrapy from scrapy.http import HtmlRespon
阅读全文
摘要:num = 0 ```Python import scrapy from scrapy.http import HtmlResponse from scrapy_demo.items import DoubanItem """ 这个例子主要是学习meta传参。 """ class DoubanSpi
阅读全文
摘要:假设我们在settings.py定义了一个IP地址池 ```Bash ##### 自定义设置 IP_PROXY_POOL = ( "127.0.0.1:6789", "127.0.0.1:6789", "127.0.0.1:6789", "127.0.0.1:6789", ) ``` 要在爬虫文件中
阅读全文
摘要:```Python # Scrapy settings for scrapy_demo project # # For simplicity, this file contains only settings considered important or # commonly used. You
阅读全文
摘要:```Python import scrapy from scrapy.http.request import Request from scrapy.http.response.html import HtmlResponse from scrapy_demo.items import Forum
阅读全文
摘要:# 创建项目 **执行命令** ```Bash scrapy startproject ``` # **项目结构** 
阅读全文
摘要:有些网站时一直滚动就会加载新数据的,在selenium中解决方法: ```Python def loaddata_by_scroll(self, driver): js = 'return document.body.scrollHeight;' # 获取当前高度 check_height = dr
阅读全文
摘要:```Python """ P.S:需要接管现有浏览器 ** 使用步骤: 1、打开浏览器,设置好远程调试端口,并扫描登录淘宝。 chrome.exe --remote-debugging-port=9333 --user-data-dir="G:\spider_taobao"** 2、运行程序,自动
阅读全文
摘要:[https://www.selenium.dev/documentation/webdriver/waits/](https://www.selenium.dev/documentation/webdriver/waits/) 有时候我们需要等待网页上的元素出现后才能操作。selenium中可以使
阅读全文
摘要:无头模式适合的场景: - 部署到没有gui界面的服务器,比如linux - 开发环境测试完全没问题后可以使用无头模式,提高selenium速度。 ```YAML # 使用headless无界面浏览器模式 chrome_options.add_argument('--headless') chrome
阅读全文
摘要:这玩意一般般、OCR可以试试EasyOcr、飞桨OCR、 ```Python """ Tesseract 就是谷歌开源的一个OCR光学文字识别引擎 默认已经有训练好的库了,但它还可以加载别人训练好的库。 使用: 1、根据平台安装引擎 这里有一个【曼海姆大学图书馆】的封装版本 https://gith
阅读全文
摘要:```Python import random import time from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.chrome.service
阅读全文
摘要:[https://www.selenium.dev/documentation/webdriver/actions_api/](https://www.selenium.dev/documentation/webdriver/actions_api/) 注意:对于滚轮的操作,只支持chrome浏览器
阅读全文
摘要:[https://www.selenium.dev/documentation/webdriver/elements/file_upload/](https://www.selenium.dev/documentation/webdriver/elements/file_upload/) 用的方法就
阅读全文
摘要:# 查找元素 官方文档:[https://www.selenium.dev/documentation/webdriver/elements/locators/](https://www.selenium.dev/documentation/webdriver/elements/locators/)
阅读全文
摘要:# 浏览器属性 > 在使用selenium过程中,实例化driver对象后,driver对象有一些常用的属性和方法 1. `driver.page_source` 当前标签页浏览器渲染之后的网页源代码。 2. `driver.current_url` 当前标签页的url。 3. `dirver.ti
阅读全文
摘要:```Python import time from selenium import webdriver from selenium.webdriver.chrome.service import Service as ChromeService # 驱动文件所在路径 DIRVER_PATH = r
阅读全文
摘要:```Python import os import random import re import sys import time import urllib.parse import requests from lxml import etree from lxml.etree import _
阅读全文
摘要:```Python import json import os import requests from lxml import etree from lxml.etree import _Element class DoubanMovieSpider(object): def __init__(s
阅读全文
摘要:lxml主要用xpath、css选择器等来提取xml格式文档,html也是xml格式文档的一种。 - xpath方法返回列表的三种情况 - 返回空列表:没有找到任何元素 - 返回字符串列表:xpath规则匹配用了`@属性`或者`text()等函数`返回`str`(文本内容或某属性的值) - 返回由_
阅读全文
摘要:又是xpath.... 10年前学java就学过了...哈哈哈 要就看w3cschool的教程就行了, **函数部分会用得到:** [https://www.w3school.com.cn/xpath/xpath_functions.asp](https://www.w3school.com.cn/
阅读全文
摘要:```Python import datetime import json import re import requests class Kr36(object): def __init__(self): self.url = "https://36kr.com/information/web_n
阅读全文
摘要:```Python import json if __name__ == '__main__': import requests resp = requests.post( url="http://ifanyi.iciba.com/index.php?c=trans&m=fy&client=6&au
阅读全文
摘要:```Python import requests url = "https://sam.huat.edu.cn:8443/selfservice/" # 默认不忽略ssl证书,如果有证书问题的网站会报错 # response = requests.get(url) # 设置verify=False
阅读全文
摘要:使用proxies参数传递代理信息 ```Python import requests if __name__ == '__main__': proxies = { # 这个字典的key不可以乱写,必须是http和https # 如果你的只有http那就只写http代理,htpps也是相同的道理。
阅读全文
摘要:```Python import requests if __name__ == '__main__': # Session对象实现了客户端和服务器端的每次会话保持功能。 session = requests.Session() resp = session.get("http://www.baid
阅读全文
摘要:""" 方法一:在请求头header中携带Cookie请求头信息(因为本身Cookie就是用请求头传递的....) 方法二:使用cookie参数传递cookie字典 """ from http.cookiejar import Cookie import requests.utils from re
阅读全文
摘要:出现这个问题是因为你系统上在使用代理,然后你的代理又是规则匹配的。 [https://stackoverflow.com/questions/36906985/switch-off-proxy-in-requests-library](https://stackoverflow.com/questi
阅读全文
摘要:# \[案例]爬取贴吧并保存网页文件 ```python import urllib.parse import requests class TiebaSpider(object): def __init__(self, url, name): self.url = url self.name =
阅读全文
摘要:# 基本使用 # 发送get请求、获取响应各种请求、响应信息 ```python def fun1(): url = "http://www.baidu.com" resp = requests.get(url) print(resp) # 打印时会发现乱码 # 因为resp默认是自动推算编码的,经
阅读全文