爬取知名社区技术文章_setting_5

# -*- coding: utf-8 -*-

# Scrapy settings for JobBole project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     http://doc.scrapy.org/en/latest/topics/settings.html
#     http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
#     http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html

BOT_NAME = ‘JobBole‘

SPIDER_MODULES = [‘JobBole.spiders‘]
NEWSPIDER_MODULE = ‘JobBole.spiders‘

# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = ‘JobBole (+http://www.yourdomain.com)‘

# 是否遵守爬虫协议,默认遵守,改成Fals,不遵守
ROBOTSTXT_OBEY = False

# Configure maximum concurrent requests performed by Scrapy (default: 16)
#CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See http://scrapy.readthedocs.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
#DOWNLOAD_DELAY = 3
# The download delay setting will honor only one of:
#CONCURRENT_REQUESTS_PER_DOMAIN = 16
#CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
#COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False

# Override the default request headers:
#DEFAULT_REQUEST_HEADERS = {
#   ‘Accept‘: ‘text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8‘,
#   ‘Accept-Language‘: ‘en‘,
#}

# Enable or disable spider middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html

# SPIDER_MIDDLEWARES = {
#    ‘JobBole.middlewares.JobboleSpiderMiddleware‘: 543,
# }

# 图片下载配置
import os
IMAGES_URLS_FIELD = ‘img_url‘
base_dir = os.path.abspath(os.path.dirname(__file__))
IMAGES_STORE = os.path.join(base_dir, ‘images‘)

# Enable or disable downloader middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
# DOWNLOADER_MIDDLEWARES = {
#    ‘JobBole.middlewares.MyCustomDownloaderMiddleware‘: 543,
# }

# Enable or disable extensions
# See http://scrapy.readthedocs.org/en/latest/topics/extensions.html
#EXTENSIONS = {
#    ‘scrapy.extensions.telnet.TelnetConsole‘: None,
#}

# Configure item pipelines
# See http://scrapy.readthedocs.org/en/latest/topics/item-pipeline.html

ITEM_PIPELINES = {
   ‘JobBole.pipelines.JobboleImagerPipeline‘: 1,
   ‘JobBole.pipelines.SqlSave‘: 2,
}

# 数据库基本配置
SQL_DBA= {
   ‘host‘: ‘localhost‘,
   ‘db‘: ‘jobole‘,
   ‘user‘: ‘root‘,
   ‘password‘: ‘password‘,
   ‘charset‘: ‘utf-8‘,
    ‘use_unicode‘: True
}

# Enable and configure the AutoThrottle extension (disabled by default)
# See http://doc.scrapy.org/en/latest/topics/autothrottle.html
#AUTOTHROTTLE_ENABLED = True
# The initial download delay
#AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
#AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
#AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
#HTTPCACHE_ENABLED = True
#HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = ‘httpcache‘
#HTTPCACHE_IGNORE_HTTP_CODES = []
#HTTPCACHE_STORAGE = ‘scrapy.extensions.httpcache.FilesystemCacheStorage‘

  

时间: 2024-11-17 08:04:07

爬取知名社区技术文章_setting_5的相关文章

爬取知名社区技术文章_分析_1

软件运行环境是什么? python 3.50                                      -- 解释器 scrapy库                                         -- 爬虫框架 pymsql库                                         -- 连接mysql数据库 pillow库                                           -- 下载图片 目标网站是什么

爬取知名社区技术文章_items_2

item中定义获取的字段和原始数据进行处理并合法化数据 #!/usr/bin/python3 # -*- coding: utf-8 -*- import scrapy import hashlib import re from scrapy.loader.processors import (MapCompose, TakeFirst, Join) from scrapy.loader import ItemLoader def go_md5(value): # 对cont_url进行md5,

爬取知名社区技术文章_article_3

爬虫主逻辑处理,获取字段,获取主url和子url #!/usr/bin/python3 # -*- coding: utf-8 -*- import scrapy from scrapy.http import Request from urllib import parse from JobBole.items import JobboleItem, ArticleItemLoader class ExampleSpider(scrapy.Spider): name = 'jobbole' #

爬取知名社区技术文章_pipelines_4

获取字段的存储处理和获取普通的路径 #!/usr/bin/python3 # -*- coding: utf-8 -*- import pymysql import gevent import pymysql from gevent import monkey from scrapy.pipelines.images import ImagesPipeline from twisted.enterprise import adbapi import pymysql.cursors class J

使用IP代理池和用户代理池爬取糗事百科文章

简单使用IP代理池和用户代理池的爬虫 import re import random import urllib.request as urlreq import urllib.error as urlerr #用户代理池 uapools = [ "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x

Python爬虫新手教程:爬取了6574篇文章,告诉你产品经理在看什么!

作为互联网界的两个对立的物种,产品汪与程序猿似乎就像一对天生的死对头:但是在产品开发链条上紧密合作的双方,只有通力合作,才能更好地推动项目发展.那么产品经理平日里面都在看那些文章呢?我们程序猿该如何投其所好呢?我爬取了人人都是产品经理栏目下的所有文章,看看产品经理都喜欢看什么. 1. 分析背景 1.1. 为什么选择「人人都是产品经理」 人人都是产品经理是以产品经理.运营为核心的学习.交流.分享平台,集媒体.培训.招聘.社群为一体,全方位服务产品人和运营人,成立8年举办在线讲座500+期,线下分享

Python爬取CSDN博客文章

之前解析出问题,刚刚看到,这次仔细审查了 0 url :http://blog.csdn.net/youyou1543724847/article/details/52818339Redis一点基础的东西目录 1.基础底层数据结构 2.windows下环境搭建 3.java里连接redis数据库 4.关于认证 5.redis高级功能总结1.基础底层数据结构1.1.简单动态字符串SDS定义: ...47分钟前1 url :http://blog.csdn.net/youyou1543724847/

使用Scrapy来爬取自己的CSDN文章

前言 爬虫作为一中数据搜集获取手段,在大数据的背景下,更加得到应用.我在这里只是记录学习的简单的例子.大牛可以直接使用python的url2模块直接抓下来页面,然后自己使用正则来处理,我这个技术屌丝只能依赖于框架,在这里我使用的是Scrapy. install 首先是python的安装和pip的安装. sudo apt-get install python python-pip python-dev 然后安装Scrapy sudo pip install Scrapy 在安装Scrapy的过程中

爬虫爬取“吟”的技术博客

下午事情少,顺便把昨天的爬虫练习下,平时都看磊的技术博哥(干货比较多):就试试先写一个简单的爬虫,后期有机会再完善,做整站和多线程. 1.观察爬取的URL: 通过观察我们发现,在首页部分包含有文章的标题列表,然后思路就是:通过这一页的url可以获取所有文章标题,再通过标题获取到文章的URL,在通过RUL下载: 观察这一页的URL为: http://dl528888.blog.51cto.com/2382721/p-1:第二页往后类推就是p-2..p-*,这样就很容易把整站都爬下来(这里只是取第一