随笔分类 - python 爬虫
摘要:1、在spider文件夹同级目录创建commands python包 2、在包下创建command.py文件 3、从scrapy.commands包下引入ScrapyCommand 4、创建一个类,继承ScrapyCommand 5、重新定义类变量 requires_project = True 6
阅读全文
摘要:第一步:安装berkeleydb数据库 第二部:pip install bsddb3 第三部:pip install scrapy-deltafetch 第四部: settings.py设置 SPIDER_MIDDLEWARES = { ‘scrapy_deltafetch.DeltaFetch’:
阅读全文
摘要:#!/usr/bin/env python# -*- encoding: utf-8 -*-# Created on 2018-08-19 14:47:28# Project: HBGGZY_SBJ import jsonimport pymongoimport hashlibfrom bs4 im
阅读全文
摘要:#encoding:utf8import pymongoimport MySQLdbimport randomdef GetMongoData(): MyQuery = Mongo_Tab.find({'is_indb':"0"}) if MyQuery.count() > 0: return My
阅读全文
摘要:class ProjectnameDownloaderMiddleware(object): # Not all methods need to be defined. If a method is not defined, # scrapy acts as if the downloader mi
阅读全文
摘要:1、倒入random模块 2、在settings文件中添加useragent列表
阅读全文
摘要:1、在settings文件中添加ip池 IPPOOL=['xxx.xx.xx.xx','xxx.xx.xxx.xx'] 2、在middleware文件中添加自己的代理ip类(首先需要导入ipPOOL,random模块) class Myproxymiddleware(object): def __i
阅读全文
摘要:1、在setting中设置MySQL连接信息 HOST=''MYSQL_DBNAME='anttest'MYSQL_PASSWORD=''MYSQL_USER='root'2、在pipeline中添加mysql异步连接类 from twisted.enterprise import adbapi i
阅读全文
摘要:#encoding:utf8 import time import redis conn = redis.Redis('localhost',db=1) #连接诶数据库并使用数据库1 def insert_data(): while True: conn.lpush('key','value') 向key中增加值 time....
阅读全文

浙公网安备 33010602011771号