作者文章归档:陈海峰

[ djangoblog项目搭建[kubesphere流水线] ]


djangoblog项目地址

本文使用了kubeshphere搭建的k8s平台并添加了devploy流水线部署

前端pod文件nginx_deploy.yaml - 39行volumeMounts为配置文件挂载, 需要提前创建好配置字典

kind: Deployment
apiVersion: apps/v1
metadata:
  name: django-blog-nginx
  namespace: chf-object
  labels:
    app: django-blog-nginx
spec:
  replicas: 1
  selector:
    matchLabels

< Read more >

[ 腾讯云短信第三方服务 ]


腾讯云短信api

腾讯云sdk安装

腾讯云短信管理页

免费领取100条

1. 申请签名

2. 模板申请

3. 等待审核

4. 去api调试

发送的json格式

{
  "PhoneNumberSet": [
    "+8617666292938",
    "+8613113003318"
  ],
  "SmsSdkAppId": "1400832200",
  "SignName": "欧欧知道个人网",
  "TemplateId&quo

< Read more >

[ nginx配置文件 ]


路由匹配规则

案例1:

输入: 127.0.0.1:8000/api/chf/

location ^~/api/ {
    proxy_pass http://11.11.11.11:8000/;
}

输出: http://11.11.11.11:8000/chf

案例2:

输入: 127.0.0.1:8000/api/chf/

location ^~/api {
    proxy_pass http://11.11.11.11:8000;
}

输出: http://11.11.11.11:8000/api/chf/

配置文件

default.conf

server {
    l

< Read more >

[ qq第三方登录 ]


QQ第三方登录

qq图片

https://qzonestyle.gtimg.cn/qzone/vas/opensns/res/img/Connect_logo_7.png

获取code

https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=102056166&redirect_uri=https://www.chfwork.cloud/login&state=test&display=pc

获取token

https://graph.qq.com/oauth2.0/token?g

< Read more >

[ selenium防检测 ]


selenium防检测

配合unittest使用实例

from django.test import TestCase
from selenium import webdriver
import time


class UserAuthTestCase(TestCase):
    @classmethod
    def setUpClass(cls):
        print("开始")

    @classmethod
    def tearDownClass(cls):
        print("结束")

    def setU

< Read more >

[ unittest自带测试库 ]


python自带unittest测试库

import unittest, sys, os
"""
1. 每个测试文件必须test_开头.py
2. 把要测试的内容引入进来, 方便
3. class必须继承TestCase
4. method必须以test_开头
"""
class TestSeleiumn(unittest.TestCase):

    @unittest.skipIf(sys.platform == "win32", "windows系统不允许")
    # @unitte

< Read more >

[ gerapy-scrapy可视化 ]


gerapy可视化爬虫

  1. 前提条件

    • 写好的scrapy爬虫项目
    • 安装, 并运行scrapyd提供项目对接端口6800
  2. 安装

pip install gerapy
  1. 初始化
    • 自动会创建可视化项目
gerapy init
  1. 生成数据库迁移
gerapy migrate
  1. 运行
gerapy runserver
  1. 主机管理
端口号写6800
  1. 项目管理
    1. 点击部署进入
    2. 打包项目把写好的scrapy导入, 打包成压缩包,或者直接复制项目到gerapy里的project文件夹里面
    3. 点击部署
  1. 执行
    1.

< Read more >

[ scrapy分布式爬虫基础 ]


scrapy基本使用

  1. 安装
pip install scrapy
  1. 创建项目
scrapy startporject 项目名
  1. 创建爬虫文件
cd 项目名 # 进入项目文件夹
scrapy genspider chf www.xxxx.com # chf是爬虫文件名, www.xxx.com是要爬的网站域名
  1. 运行
    • 保存为jsn文件
    • 保存为csv文件
scrapy crawl 爬虫文件名 -o wangzhan.json
或
scrapy crawl 爬虫文件名 -o wangzhan.csv

< Read more >