针对这种招聘信息,使用crawlscrapy很适合。

1、settings.py

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

# Scrapy settings for gosuncn project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
# https://doc.scrapy.org/en/latest/topics/settings.html
# https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
# https://doc.scrapy.org/en/latest/topics/spider-middleware.html BOT_NAME = 'gosuncn' SPIDER_MODULES = ['gosuncn.spiders']
NEWSPIDER_MODULE = 'gosuncn.spiders' LOG_LEVEL="WARNING"
LOG_FILE="./gxx.log"
# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'gosuncn (+http://www.yourdomain.com)' # Obey robots.txt rules
ROBOTSTXT_OBEY = True # Configure maximum concurrent requests performed by Scrapy (default: 16)
#CONCURRENT_REQUESTS = 32 # Configure a delay for requests for the same website (default: 0)
# See https://doc.scrapy.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 https://doc.scrapy.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
# 'gosuncn.middlewares.GosuncnSpiderMiddleware': 543,
#} # Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
#DOWNLOADER_MIDDLEWARES = {
# 'gosuncn.middlewares.GosuncnDownloaderMiddleware': 543,
#} # Enable or disable extensions
# See https://doc.scrapy.org/en/latest/topics/extensions.html
#EXTENSIONS = {
# 'scrapy.extensions.telnet.TelnetConsole': None,
#} # Configure item pipelines
# See https://doc.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
'gosuncn.pipelines.GosuncnPipeline': 300,
} # Enable and configure the AutoThrottle extension (disabled by default)
# See https://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 https://doc.scrapy.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'

2、pipelines.py

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

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html import logging
import re
logger = logging.getLogger(__name__)
class GosuncnPipeline(object):
def process_item(self, item, spider):
"""
数据处理在pipelines中进行
:param item:
:param spider:
:return:
"""
item["job_responsible"] = re.sub(r"<p>\r\n ","",item["job_responsible"])
item["job_responsible"] = re.sub(r"\r\n </p>", "", item["job_responsible"])
item["job_responsible"] = re.sub(r"(<br>{1,2})", "", item["job_responsible"])
item["job_responsible"] = re.sub(r"\t", "", item["job_responsible"])
logger.warning(item)
print(item)
return item

3、gxx.py

# -*- coding: utf-8 -*-
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule import re
import logging
logger = logging.getLogger(__name__)
class GxxSpider(CrawlSpider): name = 'gxx'
allowed_domains = ['gosuncn.zhiye.com']
start_urls = ['https://gosuncn.zhiye.com/social/?PageIndex=1'] rules = (
Rule(LinkExtractor(allow=r'/zpdetail/\d+\?PageIndex=\d'), callback='parse_item',), #获取详情页信息
Rule(LinkExtractor(allow=r'/social/\?PageIndex=\d+'), follow=True), #翻页
) def parse_item(self, response):
item = {}
item["job_name"] = response.xpath("//div[@class='boxSupertitle']/span/text()").extract_first() #工作名
ul_list = response.xpath("//div[@class='xiangqingcontain']/ul[1]")
for ul in ul_list:
item["recuirt_type"] = ul.xpath("./li[2]/text()").extract_first()
item["recuirt_type"] = re.sub("\r\n ", "", item["recuirt_type"])#招聘类型
item["recuirt_type"] = re.sub("\r\n ", "", item["recuirt_type"])
item["job_type"] = ul.xpath("./li[4]/text()").extract_first()
item["job_type"] = re.sub("\r\n ", "", item["job_type"])
item["job_type"] = re.sub("\r\n ", "", item["job_type"]) #工作类型
item["pay_money"] = ul.xpath("./li[6]/text()").extract_first() #薪资
item["pay_money"] = re.sub("\r\n ", "", item["pay_money"]) # 招聘类型
item["pay_money"] = re.sub("\r\n ", "", item["pay_money"]) item["publish_time"] = re.findall("20\d+\-\d+\-\d+", response.body.decode())[0] # 发布时间
item["recuirt_num"] = ul.xpath("./li[8]/text()").extract_first() #招聘人数
item["recuirt_num"] = re.sub("\r\n ", "", item["recuirt_num"]) # 招聘类型
item["recuirt_num"] = re.sub("\r\n ", "", item["recuirt_num"]) item["job_place"] = response.xpath("//div[@class='xiangqingcontain']/ul[3]/li[2]/text()").extract_first()
item["job_place"] = re.sub("\r\n\r\n ", "", item["job_place"]) # 招聘类型
item["job_place"] = re.sub("\r\n ", "", item["job_place"])
#logger.warning(item)
#print(item) item["job_responsible"] = response.xpath("//div[@class='xiangqingtext']/p[2]").extract_first() yield item
# for li in li_list:
# li.xpath("") #item["publish_time"] =response.xpath("/html/body/div/div[3]/div/div[1]/div/div/div/div[2]/ul[2]/li[2]/text()").extract_first()
#
#item["publish_time"] = re.findall("20\d+\-\d+\-\d+",response.body.decode())[0] #发布时间 #item['domain_id'] = response.xpath('//input[@id="sid"]/@value').get()
#item['name'] = response.xpath('//div[@id="name"]').get()
#item['description'] = response.xpath('//div[@id="description"]').get()
#print(item)
#return item

python之crawlscrapy爬取某集团招聘信息以及招聘详情的更多相关文章

  1. python之scrapy爬取某集团招聘信息以及招聘详情

    1.定义爬取的字段items.py # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See do ...

  2. [Python爬虫] Selenium爬取新浪微博客户端用户信息、热点话题及评论 (上)

    转载自:http://blog.csdn.net/eastmount/article/details/51231852 一. 文章介绍 源码下载地址:http://download.csdn.net/ ...

  3. Python爬虫项目--爬取自如网房源信息

    本次爬取自如网房源信息所用到的知识点: 1. requests get请求 2. lxml解析html 3. Xpath 4. MongoDB存储 正文 1.分析目标站点 1. url: http:/ ...

  4. 【Python项目】爬取新浪微博个人用户信息页

    微博用户信息爬虫 项目链接:https://github.com/RealIvyWong/WeiboCrawler/tree/master/WeiboUserInfoCrawler 1 实现功能 这个 ...

  5. python之scrapy爬取某集团招聘信息

    1.创建工程 scrapy startproject gosuncn 2.创建项目 cd gosuncn scrapy genspider gaoxinxing gosuncn.zhiye.com 3 ...

  6. Python爬虫项目--爬取某宝男装信息

    本次爬取用到的知识点有: 1. selenium 2. pymysql 3  pyquery 正文 1. 分析目标网站 1. 打开某宝首页, 输入"男装"后点击"搜索&q ...

  7. Python爬虫之爬取慕课网课程评分

    BS是什么? BeautifulSoup是一个基于标签的文本解析工具.可以根据标签提取想要的内容,很适合处理html和xml这类语言文本.如果你希望了解更多关于BS的介绍和用法,请看Beautiful ...

  8. Python:将爬取的网页数据写入Excel文件中

    Python:将爬取的网页数据写入Excel文件中 通过网络爬虫爬取信息后,我们一般是将内容存入txt文件或者数据库中,也可以写入Excel文件中,这里介绍关于使用Excel文件保存爬取到的网页数据的 ...

  9. [python] 常用正则表达式爬取网页信息及分析HTML标签总结【转】

    [python] 常用正则表达式爬取网页信息及分析HTML标签总结 转http://blog.csdn.net/Eastmount/article/details/51082253 标签: pytho ...

随机推荐

  1. Man手册--nmap

    目录 nmap使用手册 附录: nmap使用手册 附录: NMAP(1) Nmap Reference Guide NMAP(1) NAME nmap - Network exploration to ...

  2. com.android.ddmlib.adbcommandrejectedexception:未经授权的设备。

    出现这种问题的原因是adb被杀死了,根据网上的说法在platform-tools下双击adb.exe 也启动不了. 在命令提示符中执行    adb kill-server adb start-ser ...

  3. Java中Static关键字详解以及静态变量和成员变量的区别

    一.static关键字的特点 (1)修饰成员变量.成员方法(2)随着类的加载而加载(3)优先于对象存在(4)被所有对象共享(5)可以通过类名调用 它本身也可以通过对象名调用 例如:main()方法由j ...

  4. 一步步实现ArcMenu效果

    先来看一下最终要实验的效果: 是不是跟国外的一款Path的菜单效果类似,这里的动画采用补间动画去实现,正而操练一下补间动画. 布局和子视图的测量处理: 新建一自定义View继承ViewGroup: 然 ...

  5. 双端队列 C. Vasya and String

    High school student Vasya got a string of length n as a birthday present. This string consists of le ...

  6. django国际化的简单设置

    设置国际化的具体步骤: 一.国际化 1)效果:针对不同的国家的人可以配置不同的语言(一般是英文和中文,  English  Chinese) 2)目的:增加项目的用户量 3)难度:不难 比较费劲的就是 ...

  7. Redis入门(二)——基本操作

    Redis作为独立的服务端,在Java中去操作redis需要通过Redis提供的jar z在这里特别申明,除了基本数据以及String外,其余对象,要想写入redis,必须序列化(即使是对象也要实现序 ...

  8. python_tkinter组件

    1.按钮 # 按钮 # bg设置背景色 btn = tkinter.Button(root,text = '按钮',bg = 'red') btn.pack() # fg设置前景色(文字颜色) btn ...

  9. 手摸手教你让Laravel开发Api更得心应手

    https://www.guaosi.com/2019/02/26/laravel-api-initialization-preparation/ 1. 起因 随着前后端完全分离,PHP也基本告别了v ...

  10. Bootstrap-轮播图-No.8

    <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...