Redis REmote DIctionaryServer(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。通常被称为数据结构服务器,因为值(value)可以是字符串(String), 哈希(Map), 列表(list), 集合(sets)和 有序集合(sorted sets)等类型1.下载Redishttps://github.com/MicrosoftArch...
Scrapy--设置代理ip 本次使用的代理Ip是蘑菇代理,数据库是redis1.settings配置"""REDIS 配置链接"""REDIS_URL = "redis://127.0.0.1:6379"RETRY_TIMES = 22.写入工具类import requestsimport jsonimport timeimport redisfrom 项目名.settings import REDIS_URL...
Ubuntu下安装Python虚拟环境 1.安装 virtualenvwrapper:pip install virtualenvwrapper默认 virtualenvwrapper 安装在 /usr/local/bin 下面2. 接着创建一个文件夹来存放虚拟环境,如:mkdir $HOME/.virtualenvs3.需要配置下 ~/.bashrc,将 virtualenv 添加进去export WORKON_HOME=$HOME/...
Ubuntu下安装Python环境 ubuntu本身是有Python2.7版本的,但是不同版本的ubuntu中的Python3的版本是不同的,此处安装的是Python3.6版本1. 安装python36(非必需) 在终端中输入下面的命令wget http://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz tar -xvzf Python-3.6.4.tgz cd Pyth...
数据库--概论 我所学的数据库中有关系型数据库sqlite,SQLServer和MySQL,NoSql数据库Redis和MongoDB关系型数据库 关系型数据库是建立在关系模型基础上的数据库,借助于集合袋鼠等数据概念和方法来处理数据库中的数据。 特点如下: 数据以表格的形式出现每行为各种记录名称 每列为记录名称所对应的数据域许多的行和列组成一张表单若干的表单组成databa...
基于python的-布隆去重的方式 # -*- coding:utf-8 -*-""" 布隆去重的方式:1.使用scrapy自带的set集合去重,当程序结束set集合会被清空,再次运行会导致数据重复2.使用mysql做去重,对url地址进行MD5,Base64加密,加密之后会得到一串字符,判断字符串是否在mysql表中,如果在表示已经爬取过,如果不在,表示没有爬取,执行请求,将加密后的url地址存入表中3.使用sc...
基于python的-scrapy数据流 # -*- coding:utf-8 -*-"""Scrapy中的数据流由执行引擎控制,其过程如下: 1. 引擎打开一个网站(open a domain),找到处理该网站的Spider并向该spider请求第一个要爬取的URL(s)。 2. 引擎从Spider中获取到第一个要爬取的URL并在调度器(Scheduler)以Request调度。 3. 引擎向调度器请求下...
基于Python的-scrapyd部署爬虫流程 1. 打开命令窗口,新建一个虚拟环境:Mkvirtualenv --python=D:\python36\python.exe 虚拟环境名2. 安装scrapy项目中所需要的包:例如pip install scrapy如果缺少win32 要进行pip install pywin32安装3. 安装scrapyd服务:pip install scrapyd4. 输入scrapyd,启动服务, 在浏览...
基于python的-异步写入mysql步骤 # -*- coding:utf-8 -*-'''使用异步存储的原因: 同步:写入数据速度比较慢,而爬虫速度比较快,可能导致数据最后写入不到数据库中 异步:是将爬虫的数据先放入一个连接池中,再同时将连接池的数据写入到数据库中,这样既可以 提高数据库的写入速度,同时也可以将爬取到的所有数据都写入进数据库,能保证数据的完整性''''''异步写入流程1....
基于python的-mysql基本用法 # -*- coding:utf-8 -*-import pymysql# 1. 链接数据库db = pymysql.connect( # 链接的数据库的host主机地址:默认本地数据库使用localhost或者127.0.0.1,如果是 # 远程数据库,需要设置为主机的ip地址 host = 'localhost', # 链接数据库的用户名 us...
基于python的-PIL定位截图 # -*- coding:utf-8 -*-from selenium import webdriverfrom selenium.webdriver.support.ui import WebDriverWait# 安装PIL包# pip install pillowfrom PIL import Imagedriver = webdriver.Firefox()driver....
基于python的-selenium等待操作 # -*- coding:utf-8 -*-import timefrom selenium import webdriver# 引入显式等待类WebDriverWaitfrom selenium.webdriver.support.ui import WebDriverWaitdriver = webdriver.Firefox()driver.get('http://www.b...
基于python的-selenium批量查找标签 # -*- coding:utf-8 -*-from selenium import webdriver# 引入byfrom selenium.webdriver.common.by import By# element 返回的是标签# elements 返回的是列表,里面是标签driver = webdriver.Firefox()# 打开网页driver.get('htt...
基于python的-selenium的基本用法 # -*- coding:utf-8 -*-''' selenium 是一个用于web应用程序测试的工具,提供一些函数,通过这些函数可以定位操作到指定的标签,这些定位标签的API函数都是用python实现的,框架底层是通过javascript实现的,完全模拟人工操作使用selenium做爬虫的目的: 有些网站通过动态加载数据的方式来展示数据,这些网站在正常发起请求的情况下...
基于python的-requests模块 # -*- coding:utf-8 -*-# requests 网络请求包,基于urllib封装第三方请求包# pip install requesrs 下载包import requests# 支持所有类型的请求# requests.get()# requests.post()# requests.delete()# requests.put()# requests.hea...
基于python的-bs4的基本用法 # -*- coding:utf-8 -*-# 需要下载bs4包 pip install bs4from bs4 import BeautifulSoupimport codecs# beautifulSoup 是python支持的一个第三方的包,作用就是用来解析html网页,提取数据# lxml第三方的解析包,解析html速度比较快,功能强大,底层是c语言实现的# 1.html源...
基于python的-爬取糗事百科(工具类) # -*- coding:utf-8 -*-import reimport sqlite3class Tools(object): @classmethod def strip_char(cls, string): ''' :param string: 要进行处理的数据 :return: 处理之后的数据 ''...
基于python的-爬取糗事百科(主文件) # -*- coding:utf-8 -*-import refrom urllib import requestfrom tools import Tools,DBManagerimport timeclass QSBKSpider(object): def __init__(self): self.url = 'https://www.qiushibai...
基于python的-爬取内涵段子 # -*- coding:utf-8 -*-import refrom urllib import request, parsefrom random import choiceimport xlwtfrom tools import Toolsclass NeiHanSpider(object): def __init__(self): self.url =...
基于python的-使用正则爬取智联招聘网 #coding:utf-8import refrom urllib import request,parse# xlwt 操作excel表格import xlwtfrom random import choice'''https://sou.zhaopin.com/jobs/searchresult.ashx?kw=python&sm=0&p=1https://s...