This commit is contained in:
2025-08-05 09:19:34 +08:00
commit 584548d006
1696 changed files with 53855 additions and 0 deletions
@@ -0,0 +1,11 @@
# Automatically created by: scrapy startproject
#
# For more information about the [deploy] section see:
# https://scrapyd.readthedocs.io/en/latest/deploy.html
[settings]
default = wangyizhaopin.settings
[deploy]
#url = http://localhost:6800/
project = wangyizhaopin
@@ -0,0 +1,18 @@
# Define here the models for your scraped items
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/items.html
import scrapy
class WangyizhaopinItem(scrapy.Item):
# define the fields for your item here like:
name = scrapy.Field()
postTypeFullName = scrapy.Field()
description = scrapy.Field()
reqEducationName = scrapy.Field()
reqWorkYearsName = scrapy.Field()
requirement = scrapy.Field()
workPlaceNameList = scrapy.Field()
@@ -0,0 +1,103 @@
# Define here the models for your spider middleware
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/spider-middleware.html
from scrapy import signals
# useful for handling different item types with a single interface
from itemadapter import is_item, ItemAdapter
class WangyizhaopinSpiderMiddleware:
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the spider middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_spider_input(self, response, spider):
# Called for each response that goes through the spider
# middleware and into the spider.
# Should return None or raise an exception.
return None
def process_spider_output(self, response, result, spider):
# Called with the results returned from the Spider, after
# it has processed the response.
# Must return an iterable of Request, or item objects.
for i in result:
yield i
def process_spider_exception(self, response, exception, spider):
# Called when a spider or process_spider_input() method
# (from other spider middleware) raises an exception.
# Should return either None or an iterable of Request or item objects.
pass
def process_start_requests(self, start_requests, spider):
# Called with the start requests of the spider, and works
# similarly to the process_spider_output() method, except
# that it doesnt have a response associated.
# Must return only requests (not items).
for r in start_requests:
yield r
def spider_opened(self, spider):
spider.logger.info("Spider opened: %s" % spider.name)
class WangyizhaopinDownloaderMiddleware:
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the downloader middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_request(self, request, spider):
# Called for each request that goes through the downloader
# middleware.
# Must either:
# - return None: continue processing this request
# - or return a Response object
# - or return a Request object
# - or raise IgnoreRequest: process_exception() methods of
# installed downloader middleware will be called
return None
def process_response(self, request, response, spider):
# Called with the response returned from the downloader.
# Must either;
# - return a Response object
# - return a Request object
# - or raise IgnoreRequest
return response
def process_exception(self, request, exception, spider):
# Called when a download handler or a process_request()
# (from other downloader middleware) raises an exception.
# Must either:
# - return None: continue processing this exception
# - return a Response object: stops process_exception() chain
# - return a Request object: stops process_exception() chain
pass
def spider_opened(self, spider):
spider.logger.info("Spider opened: %s" % spider.name)
@@ -0,0 +1,46 @@
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
# useful for handling different item types with a single interface
from itemadapter import ItemAdapter
class WangyizhaopinPipeline:
def open_spider(self, spider):
if spider.name == "wyzp":
print("数据爬取开始")
self.f = open("wyzp.csv", mode="a", encoding="utf-8")
def close_spider(self, spider):
if spider.name == "wyzp":
print("数据爬取结束")
if self.f:
self.f.close()
def process_item(self, item, spider):
if spider.name == "wyzp":
# csv写入
self.f.write(f"{item['name']}\n")
return item
class WangyizhaopinPipeline1:
def open_spider(self, spider):
if spider.name == "wyzp1":
print("数据爬取开始")
self.f = open("wyzp1.csv", mode="a", encoding="utf-8")
def close_spider(self, spider):
if spider.name == "wyzp1":
print("数据爬取结束")
if self.f:
self.f.close()
def process_item(self, item, spider):
if spider.name == "wyzp1":
# csv写入
self.f.write(f"{item['name']}\n")
return item
@@ -0,0 +1,95 @@
# Scrapy settings for wangyizhaopin project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
# https://docs.scrapy.org/en/latest/topics/settings.html
# https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
# https://docs.scrapy.org/en/latest/topics/spider-middleware.html
BOT_NAME = "wangyizhaopin"
SPIDER_MODULES = ["wangyizhaopin.spiders"]
NEWSPIDER_MODULE = "wangyizhaopin.spiders"
LOG_LEVEL = "WARNING"
# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = "wangyizhaopin (+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://docs.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://docs.scrapy.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
# "wangyizhaopin.middlewares.WangyizhaopinSpiderMiddleware": 543,
#}
# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
#DOWNLOADER_MIDDLEWARES = {
# "wangyizhaopin.middlewares.WangyizhaopinDownloaderMiddleware": 543,
#}
# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
#EXTENSIONS = {
# "scrapy.extensions.telnet.TelnetConsole": None,
#}
# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
"wangyizhaopin.pipelines.WangyizhaopinPipeline": 300,
"wangyizhaopin.pipelines.WangyizhaopinPipeline1": 301,
}
# Enable and configure the AutoThrottle extension (disabled by default)
# See https://docs.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://docs.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"
# Set settings whose default value is deprecated to a future-proof value
REQUEST_FINGERPRINTER_IMPLEMENTATION = "2.7"
TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
FEED_EXPORT_ENCODING = "utf-8"
@@ -0,0 +1,4 @@
# This package will contain the spiders of your Scrapy project
#
# Please refer to the documentation for information on how to create and manage
# your spiders.
@@ -0,0 +1,6 @@
# import requests
#
# url = "https://hr.163.com/api/hr163/position/queryPage"
#
# a = requests.get(url)
# print(a.text)
@@ -0,0 +1,27 @@
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
#无法传参,只能应用于数据在一个页面里传参
class TencentCrawlSpider(CrawlSpider):
name = "tencent_crawl"
allowed_domains = ["tencent.com"]
start_urls = ["https://careers.tencent.com/search.html?pcid=40001 "]
#链接提取规则
rules = (
#使用Rule类生成连接提取规则对象
# LinkExtracto 用于设置连接提取规则,一般永allow,接受正则表达式
# follow参数决定是否在提取后的响应中继续提取链接
# 设置详情页面链接提取规则
Rule(LinkExtractor(allow=r"https://careers.tencent.com/jobdesc.html?postId=\d+"), callback="parse_item"),)
# Rule(LinkExtractor(allow=r"https://careers.tencent.com/jobdesc.html?postId=\?"), callback="parse_item", follow=True),)
def parse_item(self, response):
item = {}
print(response.url)
# 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()
return item
@@ -0,0 +1,57 @@
import scrapy
import json
from wangyizhaopin.items import WangyizhaopinItem
#该项目无法翻页,需要scrapy结合selenium等模拟点击
class WyzpSpider(scrapy.Spider):
name = "wyzp"
allowed_domains = ["hr.163.com"]
start_urls = ["https://hr.163.com/job-list.html"]
def start_requests(self):
post_body = {"currentPage": 1, "pageSize": 10}
url = "https://hr.163.com/api/hr163/position/queryPage"
yield scrapy.Request(
url=url,
callback=self.parse_detail,
body=json.dumps(post_body),
method='POST',
headers={'Content-Type': 'application/json;charset=UTF-8'}
)
# yield scrapy.Request(
# url=self.start_urls[0],
# callback=self.parse,
# headers={'Content-Type': 'application/json;charset=UTF-8'}
# )
# def parse(self, response, **kwargs):
# part_url = response.xpath('//li[@class=" ant-pagination-next"]').extract_first()
# print(part_url)
# print(response.json)
#
# if part_url != response.xpath('//li[@class="ant-pagination-disabled ant-pagination-next"]').extract_first():
# pass
def parse_detail(self, response):
# 打印整个响应对象
# print(response.json())
# 解析JSON响应
data = response.json()
# print(1)
# 提取您需要的数据
for item in data['data']['list']:
info = WangyizhaopinItem()
info["name"] = item.get('name')
info["postTypeFullName"] = item.get('postTypeFullName')
info["description"] = item.get('description')
info["reqEducationName"] = item.get('reqEducationName')
info["reqWorkYearsName"] = item.get('reqWorkYearsName')
info["requirement"] = item.get('requirement')
info["workPlaceNameList"] = item.get('workPlaceNameList')
yield info
@@ -0,0 +1,57 @@
import scrapy
import json
from wangyizhaopin.items import WangyizhaopinItem
#该项目无法翻页,需要scrapy结合selenium等模拟点击
class WyzpSpider(scrapy.Spider):
name = "wyzp1"
allowed_domains = ["hr.163.com"]
start_urls = ["https://hr.163.com/job-list.html"]
def start_requests(self):
post_body = {"currentPage": 1, "pageSize": 10}
url = "https://hr.163.com/api/hr163/position/queryPage"
yield scrapy.Request(
url=url,
callback=self.parse_detail,
body=json.dumps(post_body),
method='POST',
headers={'Content-Type': 'application/json;charset=UTF-8'}
)
# yield scrapy.Request(
# url=self.start_urls[0],
# callback=self.parse,
# headers={'Content-Type': 'application/json;charset=UTF-8'}
# )
# def parse(self, response, **kwargs):
# part_url = response.xpath('//li[@class=" ant-pagination-next"]').extract_first()
# print(part_url)
# print(response.json)
#
# if part_url != response.xpath('//li[@class="ant-pagination-disabled ant-pagination-next"]').extract_first():
# pass
def parse_detail(self, response):
# 打印整个响应对象
# print(response.json())
# 解析JSON响应
data = response.json()
# 提取您需要的数据
for item in data['data']['list']:
info = WangyizhaopinItem()
info["name"] = item.get('name')
info["postTypeFullName"] = item.get('postTypeFullName')
info["description"] = item.get('description')
info["reqEducationName"] = item.get('reqEducationName')
info["reqWorkYearsName"] = item.get('reqWorkYearsName')
info["requirement"] = item.get('requirement')
info["workPlaceNameList"] = item.get('workPlaceNameList')
yield info
@@ -0,0 +1,10 @@
内容运营实习生(AI音乐)
高级游戏测试工程师(仙侠单机)
算法实习生(搜索LLM和多模态技术)
资深VFX特效设计师(界面)-第五人格
资深UI视觉设计师-七日世界
资深动画设计师-风格化在研
资深概念设计师(场景)(天下)
资深UI视觉设计师-卡通风格
概念设计专家(角色)-萤火突击
资深级UI 视觉设计师(萤火突击)
1 内容运营实习生(AI音乐)
2 高级游戏测试工程师(仙侠单机)
3 算法实习生(搜索LLM和多模态技术)
4 资深VFX特效设计师(界面)-第五人格
5 资深UI视觉设计师-七日世界
6 资深动画设计师-风格化在研
7 资深概念设计师(场景)(天下)
8 资深UI视觉设计师-卡通风格
9 概念设计专家(角色)-萤火突击
10 资深级UI 视觉设计师(萤火突击)