随笔分类 - Python
摘要:> 源码地址:[https://github.com/pineapple-cpp/bing-image-spider](https://github.com/pineapple-cpp/bing-image-spider) 保存壁纸信息到数据库 + 保存高清壁纸(约3.5G)只需70s ![imag
阅读全文
摘要:## 问题描述 aiohttp 的 getting started 入门案例是这样写的 ```python import aiohttp import asyncio async def main(): async with aiohttp.ClientSession() as session: a
阅读全文
摘要:项目场景: 测试爬虫时需要挂代理,在Charles上测试一下。 问题描述: 这是requests挂代理的代码: proxies = { 'http': 'http://127.0.0.1:8888', 'https': 'https://127.0.0.1:8888' } response = re
阅读全文
摘要:总结自Stackoverflow:How to upgrade all Python packages with pip @(文章目录) 方法一:pip命令 温馨提示:此命令仅适于Linux用户 pip list --outdated --format=freeze | grep -v '^\-e'
阅读全文
摘要:# Flask + Echarts + sklearn 做个简单的线性回归 @[TOC] Echarts官网的线性回归示例是用了echarts-stat.js这个插件https://github.com/ecomfe/echarts-stat,在前端完成训练模型和预测的操作 正好最近解除了pytho
阅读全文
摘要:# Python pandas concat 连接时指定索引顺序 一些旧的教材上,在使用concat连接时,使用join_axes参数指定顺序,但这已经过时了,因为报错。 ```python >>> import pandas as pd >>> >>> one = pd.DataFrame([[0
阅读全文
摘要:Python 进阶 线程池 1. 概述 线程池的基类是 concurrent.futures 模块中的 Executor,Executor 提供了两个子类,即 ThreadPoolExecutor 和 ProcessPoolExecutor,其中 ThreadPoolExecutor 用于创建线程池
阅读全文
摘要:@[TOC] ## jinja2原理 Flask 的render_template默认使用了jinja2的模板引擎渲染页面 demo.py ```python from flask import Flask, render_template app = Flask(__name__) @app.ro
阅读全文
摘要:## 拦截器 对接口请求进行预先处理,然后再交由控制器。(中间关卡)  比如用户如果没有登录,则
阅读全文
摘要:时间戳转为日期 time模块,使用localtime转换,再使用strftime格式化 import time timestamp = 1609834156 date = time.localtime(timestamp) format_date = time.strftime('%Y-%m-%d
阅读全文
摘要:字典很重要 字典dict 是Python中很重要的一个数据类型, 通过键值映射, 能够很好的定位查找. Django, Flask这些Web框架在做前后端分离时, 就是用字典传数据的, 因为它和列表list 配合起来, 能够很好的与json格式的数据相互转化. 用Flask + Echarts做数据
阅读全文
摘要:Python Flask 框架 .............. 数据库链接池 pip3 install pymysql dbutils 简单实现 ''' @Date : 2020-11-12 20:02:49 @LastEditors : Pineapple @LastEditTime : 2020-
阅读全文
摘要:随便写一个装饰器: def pine(func): def inner(*args, **kwargs): """This is inner""" return func(*args, **kwargs) return inner @pine def apple(): """This is appl
阅读全文
摘要:Numpy中,给定范围内取随机数: numpy.random.randint(low, high=None, size=None, dtype=int) 从低(包含)到高(不含)返回随机整数。 如果只传参数low, 那么得到的随机数将小于low(不包括low), 随机值的区间为[0, low) >>
阅读全文
摘要:## 一、问题描述 代码 ```python ''' @Date : 2020-10-20 14:17:15 @LastEditors : Pineapple @LastEditTime : 2020-10-30 17:42:21 @FilePath : /Bus_station/#test.py
阅读全文
摘要:## 一、前言 今天是1024程序员节,大家节日快乐。听说今天发博客会得一枚1024勋章,一年一次呢,真是稀有。写篇博客顺便把这几天学习的相关知识总结一下。 ## 二、为什么要学习反爬虫 从暑假算起到现在,我也接触了4个月的爬虫,期间做过不少测试和实战,越往后学,越是难学。倒不是难在设计爬虫,编写P
阅读全文
摘要:random.getrandbits(k) 返回带有 k 位随机的Python整数。 此方法随 MersenneTwister 生成器一起提供,其他一些生成器也可以将其作为API的可选部分提供。 如果可用,getrandbits() 启用 randrange() 来处理任意大范围。 在 3.9 版更
阅读全文
摘要:## Github项目链接: [https://github.com/Pineapple666/TaobaoSpider](https://github.com/Pineapple666/TaobaoSpider) ## 一、问题描述 我一开始写爬虫的时候,数据用的是Linux虚拟机的`mysql5
阅读全文
摘要:今天在DEBUG的时候又出现了一个问题,用Scrapy下载图片,需要重写ImagesPipeline类的item_completed方法。 书上代码如下: ```python def item_completed(self, results, item, info): image_paths = [
阅读全文
摘要:## 一、前言 大概是一个月前就开始做淘宝的爬虫了,从最开始的用selenium用户配置到selenium模拟登录,再到这次的post请求模拟登录。一共是三篇博客,记录了我爬取淘宝网的经历。期间也有朋友向我提出了不少问题,比如滑块失败,微博登录失败等,可以说用selenium模拟登录这方面,坑特别多
阅读全文