python之常用开发包
1.passlib (https://passlib.readthedocs.io/en/stable/)
passlib
目前常见的不可逆加密算法有以下几种:
passlib是python 2&3的密码散列库,它提供 超过30种密码散列算法的跨平台实现,以及 作为管理现有密码哈希的框架。它被设计成有用的 对于范围广泛的任务,从验证/etc/shadow中找到的散列到 为多用户应用程序提供全强度密码哈希。
示例:
from passlib.apps import custom_app_context # 生成加密串
pwd = '123456'
hash_str = custom_app_context.encrypt(pwd)
print(hash_str) # 验证密码
custom_app_context.verify(pwd, self.password_hash)
2.消息队列rq (https://github.com/rq/rq)
RQ (Redis Queue)是一个简单的 Python 库,用于排队作业,并在后台使用 workers 处理作业。它得到了 Redis 的支持,而且其设计的进入门槛很低。它可以很容易地集成到你的 web 堆栈中。
安装:
pip install rq
使用示例:
jobs.py import requests def count_words(url):
return len(requests.get(url).text) app.py import time from redis import Redis
from rq import Queue
from jobs import count_words def run():
rq = Queue('default', connection=Redis())
for i in range(100):
j = rq.enqueue(count_words, 'http://nvie.com')
print('1 ', j.result)
time.sleep(1)
print('2 ', j.result) if __name__ == '__main__':
run()
启动worker:
rq worker --with-scheduler
$ rq worker low high default
16:56:02 RQ worker 'rq:worker:s2.6443' started, version 0.8.1
16:56:02 Cleaning registries for queue: low
16:56:02 Cleaning registries for queue: high
16:56:02 Cleaning registries for queue: default
后面的三个参数low、high、default,就是这个Worker将要运行哪些Queue里面的Job,这个顺序很重要,排在前面的Queue里面的Job将优先被运行。
添加任务:
python app.py
同时还支持调度任务
# Schedule job to run at 9:15, October 10th
job = queue.enqueue_at(datetime(2019, 10, 8, 9, 15), say_hello) # Schedule job to be run in 10 seconds
job = queue.enqueue_in(timedelta(seconds=10), say_hello)
失败回调, 重试次数
from rq import Retry # Retry up to 3 times, failed job will be requeued immediately
queue.enqueue(say_hello, retry=Retry(max=3)) # Retry up to 3 times, with configurable intervals between retries
queue.enqueue(say_hello, retry=Retry(max=3, interval=[10, 30, 60]))
3.远程隧道链接
sshtunnel
4.代理UA
pip install fake_useragent import requests
from fake_useragent import UserAgent def get_mafengwo_content():
# 创建UserAgent对象
user_agent = UserAgent() # 设置请求头
headers = {
'User-Agent': user_agent.random
} # 目标网址
url = 'https://www.mafengwo.cn/' try:
# 发送GET请求
response = requests.get(url, headers=headers)
http://www.jshk.com.cn/mb/reg.asp?kefu=xiaoding;//爬虫IP免费获取; # 检查请求是否成功
if response.status_code == 200:
# 打印网页内容
print(response.text)
else:
print(f"Failed to fetch the page. Status code: {response.status_code}") except Exception as e:
print(f"An error occurred: {e}") if __name__ == "__main__":
get_mafengwo_content()
python之常用开发包的更多相关文章
- Python在ubuntu下常用开发包名称
build-essential python3-setuptools python-setuptools-doc python3-all-dev python3-wheelwheel时pip支持的一种 ...
- Python开发包推荐系列之xml、html解析器PyQuery
使用python,喜欢她的简洁是一方面,另外就是它有着丰富的开发包 好用又方便 接下来会给大家推荐一系列很赞的开发包. 在解析html.xml过程中,我们有不少的包可以用.比如bs.lxml.xmlt ...
- click python cli 开发包
python click 包是一个方便的cli 开发包,我们可以用来开发强大的cli 应用 使用venv 进行环境准备,示例代码来自官方 venv 环境准备 python3 -m venv demoa ...
- [Python Day5] 常用模块
目录: 1.模块介绍 2.time & datetime 3.random 4.OS 5.sys 6.shutil 7.json & pickle 8.shelve 9.xml 处理 ...
- Python第三方常用工具、库、框架等
Python ImagingLibrary(PIL):它提供强大的图形处理的能力,并提供广泛的图形文件格式支持,该库能进行图形格式的转换.打印和显示.还能进行一些图形效果的处理,如图形的放大.缩小和旋 ...
- SVG开发包, 20 个有用的 SVG 工具,提供更好的图像处理
20 个有用的 SVG 工具,提供更好的图像处理 SVG 现正在 Web 设计领域变得越发流行, 你可以使用 Illustrator 或者 Inkscape 来创建 SVG 图像. 但当进行 Web ...
- Python的常用库
读者您好.今天我将介绍20个属于我常用工具的Python库,我相信你看完之后也会觉得离不开它们.他们是: Requests.Kenneth Reitz写的最富盛名的http库.每个Python程序员都 ...
- 我用的一些Node.js开发工具、开发包、框架等总结
开发工具 1.WebStorm,毫无疑问非他莫属,跨平台,强大的代码提示,支持Nodejs调试,此外还支持vi编辑模式,这点我很喜欢. 2.做些小型项目用Sublime Text. 3.Browser ...
- VB短信猫开发包,支持超长短信
一.短信猫开发包(长短信/异步调用)说明: 短信猫开发包以OCX控件的形式提供,支持Windows平台下常用的开发工具:如VB.VB.net.VC++.Power Builder.C#.DELPH ...
- Node.js开发工具、开发包、框架等总结
开发工具 1.WebStorm,毫无疑问非他莫属,跨平台,强大的代码提示,支持Nodejs调试,此外还支持vi编辑模式,这点我很喜欢.2.做些小型项目用Sublime Text.3.Browserif ...
随机推荐
- [Udemy] AWS Certified Data Analytics Specialty - 5.Visualization
QuickSight SPICE是 QuickSight 的加速技术
- containerd 拉取k8s.gcr.io/pause镜像i/o timeout
由于k8s.gcr.io 需要连外网才可以拉取到,导致 k8s 的基础容器 pause 经常无法获取.k8s docker 可使用代理服拉取,再利用 docker tag 解决问题 docker pu ...
- Servlet——执行流程、生命周期、方法介绍、体系结构
执行流程 生命周期 对象的生命周期是指一个对象从被创建到被销毁的整个过程 Servlet运行在Servlet容器(web服务器)中,其生命周期由容器管理,分为四个阶段: 1. 加载和实例 ...
- 获取form提交的返回值
获取form提交的返回值 HTML代码如下: <form action="" method="post" enctype="multipart/ ...
- php中的跳转
php中的跳转 header("refresh:3;url=http://www.baidu.com";); <meta http-equiv='refresh' conte ...
- flops, params = profile(model, inputs=(x,))计算
计算量:FLOPs,FLOP时指浮点运算次数,s是指秒,即每秒浮点运算次数的意思,考量一个网络模型的计算量的标准.参数量:Params,是指网络模型中需要训练的参数总数. flops(G) = flo ...
- Java日期时间API系列17-----Jdk8中java.time包中的新的日期时间API类,java日期计算4,2个日期对比,获取相差年月日部分属性和相差总的天时分秒毫秒纳秒等
通过Java日期时间API系列9-----Jdk8中java.time包中的新的日期时间API类的Period和Duration的区别 ,可以看出java8设计非常好,新增了Period和Durati ...
- Oracle ASM磁盘组配置、日常运维、故障处理等操作资料汇总
ASM(自动存储管理)在数据库中是非常重要的组成部分,它可以为磁盘提供统一的存储管理.提高磁盘访问的性能和可用性.简化管理复杂度,从而为数据库的运行提供更好的支持. 这里就为大家整理了墨天轮数据社区上 ...
- ChallengeMobile
解题思路 获取到输入的字符串保存到s,调用Jformat方法对s进行验证,返回true则代表输入字符串正确反之错误. Jformat方法分析: 首先看到使用了LoadData加载了"ming ...
- C# 中的四种整形数据
// C# 中有四种整数类型 byte short int long byte bMax = byte.MaxValue; /// 255 最大值 byte bMin = byte.MinValue; ...