Python
迷心兔
我对你的感情大概就是,就算我们很久不说话,不聊天,或者哪天直接就没了任何联系,我还是会觉得你是我非常,非常重要的人...
展开
-
【2021-12-15】wget配合https 伪造本地环境
wget下载:https://blog.csdn.net/qq_40962368/article/details/86772419wget使用教程:https://www.cnblogs.com/klausage/p/14969260.htmlpython搭配mkcert启动本地https服务:https://blog.csdn.net/mixintu/article/details/120458000克隆网站:wget -r -p -np -k -e robots=off https://wens原创 2021-12-15 10:48:23 · 1792 阅读 · 0 评论 -
【2021-09-24】python搭配mkcert启动本地https服务
python搭配mkcert启动本地https服务原创 2021-09-24 16:38:28 · 708 阅读 · 0 评论 -
Python request-html cv2获取网络图片【canvas base64图片】
测试网站:http://www.porters.vip/captcha/clicks.htmlimport cv2import base64import numpy as npimport nest_asyncionest_asyncio.apply()from requests_html import AsyncHTMLSessionasession = AsyncHTMLSession()def remove_bg(img): cv2.imshow("img.pmg",.原创 2021-01-12 12:06:23 · 997 阅读 · 0 评论 -
python re示例学习
flags:标志位,正则表达式修饰符re.I 使匹配对大小写不敏感re.L 做本地化识别(locale-aware)匹配re.M 多行匹配,影响 ^ 和 $re.S 使 . 匹配包括换行在内的所有字符re.U 根据Unicode字符集解析字符。这个标志影响 \w, \W, \b, \B.re.X 该标志通过给予你更灵活的格式以便你将正则表达式写得更易于理解。match函数import re""" match函数从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功的话,match.原创 2021-01-09 16:09:14 · 862 阅读 · 0 评论 -
python字体获取css反爬可以用到【除非字体反爬用到图片识别】
'''translation_table = {ord('A'): ord('O'),ord('K'): ord('O')} print(translation_table )# { 65 :79 } print('MARK'.translate(translation_table) )# MORK'''characters = tuple(ord(c) for c in 'SMEDONRY') characters# (83, 77, 69, 68, 79, 78, 82, 89)g转载 2020-12-26 13:13:24 · 144 阅读 · 0 评论 -
python 计算列表n种组合 -> 得到m种排列方式
原文:https://diveintopython3.net/advanced-iterators.html>>> import itertools >>> perms = itertools.permutations([1, 2, 3], 2) >>> next(perms) (1, 2)>>> next(perms)(1, 3)>>> next(perms)(2, 1) >>>.转载 2020-12-26 12:45:49 · 449 阅读 · 1 评论 -
Python爬虫百度新闻标题
原文:https://blog.csdn.net/weixin_43881394/article/details/108200983新学requests-html模块import pandas as pdfrom requests_html import HTMLSessionsession = HTMLSession()news_dict = {}r = session.get('http://news.baidu.com/')# 提取首页新闻内容hot_news = r.html..转载 2020-11-29 00:29:22 · 992 阅读 · 0 评论 -
Python cv2 练习极验(w3c)滑动验证码
极验滑块验证:https://www.w3cschool.cn/register代码可以对换哦,拿别的极验交换就可【比如文字点选,语序点选,图片转正】测试一:1.滑块 2.模板3.结果:测试二:1.滑块2.模板3.结果:测试三:1.滑块2.模板3.结果:测试四:1.滑块2.模板3.结果:测试五:1.滑块2.模板3.结果:测试六:1.滑块2.模板3.结果:测试七:1.滑块2.模板3.结果:测试八:1.滑块2.模板3.结果:测试九:.原创 2020-11-23 22:42:19 · 683 阅读 · 1 评论 -
pyppeteer 极验(斗鱼直播 )滑动验证码【思路】
思路代码注释的代码:使用page.frames 不知道怎么注入JS获取滑块验证图,所以注释6.选择器用于选择鼠标指针浮动在上面的元素: 多次踩坑,如果没有这句,滑块就不能移动@except_output(msg='斗鱼直播 - 异常') async def test(self): [page] = await self.browser.pages() await page.setViewport(viewport={'width': self.width,.原创 2020-11-21 02:06:09 · 1636 阅读 · 1 评论 -
Pyppeteer cv2 破解极验(春秋航空)滑动验证码
春秋航空:https://account.ch.com/NonRegistrations-Registgeetest极验测试:https://blog.csdn.net/mixintu/article/details/109732640极验图的操作春秋航空好像使用geetest极验,主要代码搜索 ->在这,就增加一行代码import cv2# 获取滑块的大小def fix_img(filename): # 1.为了更高的准确率,使用二值图像 img = cv2.i.原创 2020-11-26 17:13:21 · 715 阅读 · 0 评论 -
Pyppeteer cv2 破解极验(geetest)滑动验证码
import cv2import base64import asynciofrom pyppeteer import launchlaunch_args = { "headless": False, 'executablePath': r"C:\Program Files\Google\Chrome\Application\chrome.exe", "args": [ "--start-maximized", "--disable-info.原创 2020-11-24 18:47:47 · 821 阅读 · 6 评论 -
Python cv2 定位滑块验证码的位置
测试网站:https://www.geetest.com/demo/slide-bind.html滑块:fadebg.png背景:fullbg.pngimport cv2# 显示或保存图片def cv_show(name, img, save=False): if save: cv2.imwrite(name, img) cv2.imshow(name, img) cv2.waitKey(0) cv2.destroyAllWindows().原创 2020-11-15 13:39:39 · 970 阅读 · 0 评论 -
在线制作思维导图
功能强大的在线文档制作现在开始使用在线制作思维导图语雀工作台:https://www.yuque.com/dashboard原创 2020-11-02 22:06:04 · 397 阅读 · 0 评论 -
MHyourh你好:我这里不用线程的实例对象ID不是相同的,我试了几个博主的代码也是一样【线程加锁后实例对象就一样了,不知为什么】
原文:https://blog.csdn.net/sinat_38682860/article/details/103979764类方法 一class Singleton(object): def __init__(self): pass def run(self, msg='哈喽'): self.msg = msg @classmethod def instance(cls, *args, **kwargs): .转载 2020-10-17 22:30:36 · 122 阅读 · 0 评论 -
jupyter 配合装饰器输出运行时间【全部代码执行,行内表达式执行时间】
%%time # %quickref #thon 快速参考# %magic #显示magic command详细文档import timefrom functools import wraps def timefn(fn): @wraps(fn) def measure_time(*args, **kwargs): t1 = time.time() # 图通过性能分析找到瓶颈 25 result = %time fn(*args,原创 2020-08-24 14:20:48 · 433 阅读 · 0 评论 -
浅拷贝
图片里黄色块:这是lst列表的内存地址【字符串在列表中:同样的字符内存地址一样嘛】浅拷贝print("浅拷贝")import copylst = ['str2', 'str3', 'str4']sourcelst = ['str1', 'str2', 'str3', lst]copylst = copy.copy(sourcelst)print("--->【*】sourcelst: ",id(sourcelst), sourcelst)print("***>【*】copyls转载 2020-08-12 22:58:51 · 106 阅读 · 0 评论 -
拉勾网python分析
import pandas as pdimport matplotlib.pyplot as pltplt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号data3 = pd.read_csv(r'lagou_pytho...原创 2019-12-08 20:50:26 · 224 阅读 · 0 评论 -
拉勾网java分析
import pandas as pdimport matplotlib.pyplot as pltplt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号# data3 = pd.read_csv(r'lagou_pyt...原创 2019-12-08 20:44:03 · 230 阅读 · 0 评论 -
装饰器用来跟踪函数调用
# coding=utf-8def trace(f): f.indent = 0 def g(x): print(f"{' | ' * f.indent} |-- {f.__name__} {x}") f.indent += 1 result = f(x) print(f"{' | ' * f.indent} |-...转载 2019-12-01 13:06:40 · 123 阅读 · 0 评论 -
拉钩网数据分析
import pandas as pdimport matplotlib.pyplot as pltfrom pyecharts import Bar, Geo, Map, Piedf = pd.read_csv("lagou.csv", usecols=['city', 'education', 'salary'])plt.rcParams['font.sans-serif'] = ...原创 2019-11-30 21:50:38 · 404 阅读 · 0 评论 -
timeit测试map【内置,线程,进程】
# coding=utf-8from math import sqrtfrom timeit import timeitfrom concurrent.futures.process import ProcessPoolExecutorfrom concurrent.futures.thread import ThreadPoolExecutordef increase_price_...原创 2019-11-29 23:01:13 · 108 阅读 · 0 评论 -
代码优化
# coding=utf-8def process_items(items, bar, default): if bar is None: return "No Bar" for item in items: if item.match != "B": return process_item(item, bar) r...原创 2019-11-29 23:00:21 · 83 阅读 · 0 评论 -
操作数组的基础算法
# coding=utf-8import doctestimport collectionsfrom collections.abc import Iterablefrom timeit import timeit# 操作一维数组中多余的数值(限制值为num)【适用短数组】def array_limit_count_01(array, num): # 时间复杂度O(n ^ 2)...转载 2019-11-25 16:32:58 · 132 阅读 · 0 评论 -
使用枚举类
# coding=utf-8from enum import Enum, unique# 1.Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))for name, member in Month.__members__.ite...转载 2019-11-23 11:59:52 · 633 阅读 · 0 评论 -
生成器还可以叠加来组成生成器管道
# Fibonacci数生成器def fib(): a, b = 0, 1 while True: a, b = b, a + b yield a# 偶数生成器def even(gen): for val in gen: if val % 2 == 0: yield valdef mai...转载 2019-11-21 00:23:18 · 118 阅读 · 0 评论 -
继承和多态
自己修改了一点class Person(object): """人""" def __init__(self, name, age, grade): self._name = name # 名字 self._age = age # 年龄 self._grade = grade # 等级 @property ...转载 2019-11-20 22:31:45 · 83 阅读 · 0 评论 -
运用staticmethod装饰器的简单方式
from math import sqrtclass Triangle(object): def __init__(self, a, b, c): self._a = a self._b = b self._c = c @staticmethod def is_valid(a, b, c): retu...转载 2019-11-20 19:48:54 · 203 阅读 · 0 评论 -
三种方式的阶乘
import logginglogging.basicConfig( # 用日志打印输出信息 level = logging.INFO, format = "%(asctime)s [*] %(message)s")def factorialR(N): """递归函数""" assert isinstance(N, int) and N ...转载 2019-11-20 12:41:09 · 173 阅读 · 0 评论 -
获取redis数据制作词云
# coding=utf-8# @author :迷心兔# time :2019/11/17import redisimport jiebaimport numpy as npfrom os import pathfrom PIL import Imageimport matplotlib.pyplot as pltfrom wordcloud import Wor...原创 2019-11-17 06:48:10 · 95 阅读 · 0 评论 -
词云的基础源码理解
# coding=utf-8import jiebaimport numpy as npfrom os import pathfrom random import Randomimport os, re, sys, warningsfrom collections import Counterfrom operator import itemgetterimport matplot...原创 2019-11-17 06:07:08 · 492 阅读 · 0 评论 -
在团队合作当中,使用自己的编码风格【适用元类编写】
def camel_to_snake(name): """ A function that converts camelCase to snake_case. Referred from: https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-...转载 2019-11-02 16:37:55 · 77 阅读 · 0 评论 -
素数生成器
# L = [n for n in range(2, 40)]# print(L)# L = [n for n in L if n == L[0] or n % L[0] > 0] # 除了原来的数,都去掉2的倍数# print(L)# L = [n for n in L if n == L[1] or n % L[1] > 0] # 除了原来的数,去掉3的倍数# pri...转载 2019-11-02 02:39:48 · 574 阅读 · 0 评论 -
在Django中添加装饰器
1.没有装饰器的——》Django 的注册功能def register(request): result = None # 仅检查post if request.method != 'POST': result = {"error": "此方法仅接受post!"} else: try: user = User...转载 2019-11-01 17:37:20 · 566 阅读 · 0 评论 -
无厘头的基础类型基础
message = "what do you like?"response = 'spam'# 字母全部大写print(response.upper()) # SPAM# 第一个单词的首字母大写print(message.capitalize()) # What do you like?# 全部单词的首字母大写print(message.title()) # What Do Y...转载 2019-11-01 14:22:31 · 142 阅读 · 0 评论 -
装饰器【函数无参】,【函数有参】,【函数有参且装饰器有参】
作用:为其他函数添加附加功能@wraps(func) # 变成传入的函数对象名(发现现在都不需要这个装饰器了)1.函数无参import logginglogging.basicConfig( level = logging.INFO, format = " %(asctime)s [*] %(message)s") def decorator(func): ...转载 2019-10-30 22:28:08 · 143 阅读 · 0 评论 -
第五章. 写出优雅的 Python 代码
代码结构1.什么时候用装饰器: 【https://learnku.com/docs/python-guide/2018/structure/3260】def func_01(): # 1.某个函数 # 一些操作def decorator(func): # 2.要充当装饰器的函数 # 处理 func return funcdecorator(func_01) ...转载 2019-10-30 13:48:24 · 161 阅读 · 0 评论 -
序列化的基础
# coding=utf-8import jsonimport pickle"""文件的读写,把一个字符串(或字符串)保存到磁盘是一件很容易的事情。但是在实际编程中,我们经常需要保存结构化数据。结构化数据:复杂的字典,嵌套的列表等等。序列化:把结构化数据转变成一个字符串。反序列化:序列化的逆操作。json序列化:json格式通常被现代应用程序用于数据交换,尤其是在we...转载 2019-10-30 00:25:05 · 68 阅读 · 0 评论 -
自个的基础学习网站
https://learnku.com/docs/python-guide/2018https://learnku.com/docs/python-guide/2018https://www.programcreek.com/python/?ClassName=python&submit=Searchhttps://awesome-python.com/https://www.py...原创 2019-10-29 19:57:56 · 129 阅读 · 0 评论 -
认识元类的面貌
1.元类的认识以下基本上是等效的:class Test(object): def __init__(self, x): self.x = x def printX(self): print(self.x)print(type(Test)) # <class 'type'>def __init__(self, x): ...原创 2019-10-29 14:23:15 · 191 阅读 · 0 评论 -
【函数动态创建类】,【type动态创建类和操作类】
# 1.动态创建类----------------------------------------------------------------------------------------def choose_name(name): if name == "haha": class haha(object): pass re...转载 2019-10-29 11:49:50 · 86 阅读 · 0 评论