分类标签归档:scripy

[ ip代理池 ]


python的免费ip代理池

GIT-HUB地址

1. 拉取代码

2. 修改docker-compose.yml文件内容为(指定自己的redis)

version: "3"
services:
  proxypool:
    image: "germey/proxypool:master"
    container_name: proxypool
    ports:
      - "5555:5555"
    restart: always
    environment:
      PROXYPOOL_REDIS_HOS

< Read more >

[ mp4生成m3u8文件以及切片[ffmpeg] ]


生成m3u8文件&切片

ffmpeg -i out.mp4 -vbsf h264_mp4toannexb -vcodec copy -acodec aac -strict 2 -g 150 -hls_time 20 -hls_list_size 0 -start_number 0 -f hls -y out.m3u8

新版本

ffmpeg -i out.mp4 -bsf:v h264_mp4toannexb -vcodec copy -acodec aac -strict 2 -g 150 -hls_time 20 -hls_list_size 0 -start_number 0 

< Read more >

[ 视频爬虫[python] ]


简单版本

1.案例网站

https://www.ikanbot.com/play/810009

爬取思路 - 查看网络请求情况 2 - 找到M3u8文件 3 - 获取m3u8文件请求地址 4 - 获取文件里面ts视频的请求地址 5

2.python爬虫 同步版本

import requests
import re
import os
header = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/1

< 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 >

[ 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 >

[ Selenium参考文章 ]


参考文章

  1. 安装需要先下载驱动
from selenium.webdriver.common.action_chains import ActionChains # 导包。鼠标
from selenium import webdriver # 浏览器导包
import time #时间导包
from selenium.webdriver.common.by import By # 元素导包
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expecte

< Read more >