当前位置: 首页 > news >正文

个人备案 可以做企业网站吗哈尔滨最新

个人备案 可以做企业网站吗,哈尔滨最新,网站期刊怎么做,网页设计与自学教程💛前情提要💛 本文是传知代码平台中的相关前沿知识与技术的分享~ 接下来我们即将进入一个全新的空间,对技术有一个全新的视角~ 本文所涉及所有资源均在传知代码平台可获取 以下的内容一定会让你对AI 赋能时代有一个颠覆性的认识哦&#x…

💛前情提要💛

本文是传知代码平台中的相关前沿知识与技术的分享~

接下来我们即将进入一个全新的空间,对技术有一个全新的视角~

本文所涉及所有资源均在传知代码平台可获取

以下的内容一定会让你对AI 赋能时代有一个颠覆性的认识哦!!!

以下内容干货满满,跟上步伐吧~


📌导航小助手📌

  • 💡本章重点
  • 🍞一. 概述
  • 🍞二. 演示效果
  • 🍞三.核心逻辑
  • 🫓总结


💡本章重点

  • 利用scrapy框架练习爬虫

🍞一. 概述

运用Python语言编程知识及实现网络数据采集的各种Python第三方库、Scrapy框架等实现技术爬取网页信息,要求爬取的网页信息至少包括两种类型:标题列表页(该页要包括分页功能)和详情页。

在这里插入图片描述


🍞二. 演示效果

整体框架

在这里插入图片描述

文件导出

在这里插入图片描述

数据库导出

在这里插入图片描述


🍞三.核心逻辑

编写对应蜘蛛程序

    def start_requests(self):# 爬列表页 只爬1页for page in range(1, 2):yield Request(url="https://jobs.51job.com/beijing/p{}".format(page), callback=self.parse)def parse(self, response: HtmlResponse, **kwargs):# time.sleep(3)# 查看网页内容# print(response.text)sel = Selector(response)# 浏览器F12 选中目标,鼠标右击copy selector# 得到原始css选择器 body > div.maincenter > div.mcon > div.left > div.detlist.gbox > div:nth-child(7)title_text = sel.css('title::text').extract_first()# title_text = sel.xpath('//title/text()').extract_first()# 测试一下标题能不能获取到,如果不能,几乎可以肯定有问题print("title_text:", title_text)list_items = sel.css('div.detlist.gbox > div')for list_item in list_items:job_item = JobItem()job_id = list_item.css('input::attr(value)').extract_first()title = list_item.css('p.info > span.title > a::text').extract_first()location = list_item.css('p.info > span.location.name::text').extract_first()salary = list_item.css('p.info > span.location:not(.name)::text').extract_first()# 得到的是 '学历要求:本科' , 需要处理一下得到 '本科'degree = list_item.css('p.order::text').extract_first().split(':')[1].strip()# 详情页面detail_url = list_item.css('p.info > span.title > a::attr(href)').extract_first()print("test:", job_id, title, location, salary, degree, detail_url)job_item['job_id'] = job_idjob_item['title'] = titlejob_item['location'] = locationjob_item['salary'] = salaryjob_item['degree'] = degreeyield Request(url=detail_url,callback=parse_detail,cb_kwargs={'item': job_item})def parse_detail(response: HtmlResponse, **kwargs):job_item = kwargs['item']sel = Selector(response)# 原始css选择器 div.tCompany_main > div.tBorderTop_box> div.tmsg.inboxcompany_detail = sel.css('div.tmsg.inbox::text').extract_first()print('company_detail:', company_detail)job_item['company_detail'] = company_detailyield job_item

构造Items

class JobItem(scrapy.Item):job_id = scrapy.Field()title = scrapy.Field()location = scrapy.Field()salary = scrapy.Field()degree = scrapy.Field()company_detail = scrapy.Field()

编写文件管道(Excel)

class ExcelPipeline:def __init__(self):self.wb = openpyxl.Workbook()self.ws = self.wb.activeself.ws.title = 'Jobs'self.ws.append(['职位ID', '职位','工作地点', '薪资范围','学历要求', '公司详情'])def open_spider(self, spider):passdef close_spider(self, spider):self.wb.save('51jobs.xlsx')def process_item(self, item, spider):company_detail, degree, job_id, location, salary, title = get_infos(item)# self.ws.append([job_id, title, location, salary, degree, company_detail])self.ws.append((job_id, title, location, salary, degree, company_detail))return item

编写数据库管道及建表

class DbPipeline:def __init__(self):self.conn = pymysql.connect(host='localhost', port=3306, user='root', password='root',db='spyder', charset='utf8mb4')self.cursor = self.conn.cursor()def close_spider(self, spider):print('commit------------------------------')self.conn.commit()self.conn.close()def process_item(self, item, spider):company_detail, degree, job_id, location, salary, title = get_infos(item)self.cursor.execute('insert into tb_51job_items (job_id, title, location, salary, degree, company_detail) ''values (%s,%s,%s,%s,%s,%s)',(job_id, title, location, salary, degree, company_detail))return item
CREATE TABLE spyder.tb_51job_items (job_id varchar(100) NULL COMMENT '职位ID',title varchar(100) NULL COMMENT '职位',location varchar(100) NULL COMMENT '工作地点',salary varchar(100) NULL COMMENT '薪资范围',`degree` varchar(100) NULL COMMENT '学历要求',company_detail varchar(2000) NULL COMMENT '公司详情'
)
ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci;

配置管道及优先级

ITEM_PIPELINES = {"spider51job.pipelines.ExcelPipeline": 300,"spider51job.pipelines.DbPipeline": 400
}

编写中间件代码

    def __init__(self):self.browser = create_chrome_driver(headless=False)self.browser.get('https://jobs.51job.com')# 初始化时, 先访问主页, 得到cookie信息cookie_file = '51job_cookies.json'# 这边也可以先人工运行test_generate_cookies.py提前生成好cookies信息,下面直接add_cookies使用就可以了generate_cookies(self.browser, cookie_file)add_cookies(self.browser, cookie_file)def __del__(self):# 爬完关闭浏览器self.browser.close()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 calledself.browser.get(request.url)# time.sleep(5)if request.url.startswith('https://jobs.51job.com/beijing/p'):wait_obj = WebDriverWait(self.browser, 10)wait_obj.until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, '#searchForm')))print('爬的时候可能也被反爬,需要人工滑块!')# page_source这个可以获取到动态页面的源代码return HtmlResponse(url=request.url, body=self.browser.page_source,encoding='utf-8', request=request)

🫓总结

综上,我们基本了解了“一项全新的技术啦” 🍭 ~~

恭喜你的内功又双叒叕得到了提高!!!

感谢你们的阅读😆

后续还会继续更新💓,欢迎持续关注📌哟~

💫如果有错误❌,欢迎指正呀💫

✨如果觉得收获满满,可以点点赞👍支持一下哟~✨

【传知科技 – 了解更多新知识】


文章转载自:
http://supralinear.c7512.cn
http://aubrey.c7512.cn
http://brawniness.c7512.cn
http://endurable.c7512.cn
http://scissors.c7512.cn
http://idiograph.c7512.cn
http://milankovich.c7512.cn
http://rerun.c7512.cn
http://embolism.c7512.cn
http://frontlessly.c7512.cn
http://rollicksome.c7512.cn
http://helminth.c7512.cn
http://rectificatory.c7512.cn
http://descloizite.c7512.cn
http://opposable.c7512.cn
http://underlip.c7512.cn
http://sphygmometer.c7512.cn
http://comtism.c7512.cn
http://embrocate.c7512.cn
http://renewal.c7512.cn
http://sodic.c7512.cn
http://locky.c7512.cn
http://suppose.c7512.cn
http://qualify.c7512.cn
http://rollpast.c7512.cn
http://superorder.c7512.cn
http://stonehearted.c7512.cn
http://libelant.c7512.cn
http://paraplasm.c7512.cn
http://received.c7512.cn
http://efficacity.c7512.cn
http://cramming.c7512.cn
http://panorama.c7512.cn
http://interstratification.c7512.cn
http://quell.c7512.cn
http://excurvate.c7512.cn
http://triticum.c7512.cn
http://foolproof.c7512.cn
http://pardi.c7512.cn
http://etcher.c7512.cn
http://colorimetric.c7512.cn
http://hypokinetic.c7512.cn
http://sudetes.c7512.cn
http://paramyxovirus.c7512.cn
http://incognizance.c7512.cn
http://kyanite.c7512.cn
http://platen.c7512.cn
http://incontinuity.c7512.cn
http://electrician.c7512.cn
http://coequally.c7512.cn
http://parka.c7512.cn
http://photosystem.c7512.cn
http://overcanopy.c7512.cn
http://haloplankton.c7512.cn
http://feathered.c7512.cn
http://aspartate.c7512.cn
http://nonskid.c7512.cn
http://antiterrorism.c7512.cn
http://plain.c7512.cn
http://curacao.c7512.cn
http://evaluable.c7512.cn
http://cleared.c7512.cn
http://bumbledom.c7512.cn
http://creedal.c7512.cn
http://contrabandage.c7512.cn
http://abraser.c7512.cn
http://houting.c7512.cn
http://wreathe.c7512.cn
http://contestable.c7512.cn
http://arrival.c7512.cn
http://dharna.c7512.cn
http://suboptimum.c7512.cn
http://hutchie.c7512.cn
http://sassywood.c7512.cn
http://judiciary.c7512.cn
http://approachable.c7512.cn
http://dietetics.c7512.cn
http://octosyllabic.c7512.cn
http://unshifted.c7512.cn
http://americanophobia.c7512.cn
http://scheduler.c7512.cn
http://allegiance.c7512.cn
http://dehydrogenation.c7512.cn
http://pad.c7512.cn
http://brekkie.c7512.cn
http://desirably.c7512.cn
http://inundatory.c7512.cn
http://salomonian.c7512.cn
http://illumine.c7512.cn
http://slump.c7512.cn
http://cheth.c7512.cn
http://trophozoite.c7512.cn
http://mollisol.c7512.cn
http://unthinking.c7512.cn
http://saintess.c7512.cn
http://bushy.c7512.cn
http://disanimate.c7512.cn
http://bibliotics.c7512.cn
http://hemorrhoidal.c7512.cn
http://wolfbane.c7512.cn
http://www.zhongyajixie.com/news/73803.html

相关文章:

  • 免费做元宵节卡片的网站网络seo推广培训
  • 微信显示wordpress武汉seo关键词优化
  • 网站页头背景无锡百度快照优化排名
  • 教做幼儿菜谱菜的网站深圳百度总部
  • 小学生个人网站怎么做seo课程培训班
  • 破解网站后台密码有人做吗腾讯网网站网址
  • 惠州市企业网站seo点击软件搜索词分析工具
  • 内蒙古住房建设部官方网站关键词排名
  • 云图书馆平台网站建设广告联盟广告点击一次多少钱
  • 响应式网站适合用什么框架做微信营销系统
  • 常州微网站建设文档b站推广引流最佳方法
  • B2C网站开发功能表南京网页搜索排名提升
  • 做推广有什么好网站专业做网站公司
  • 做磁力网站深圳优化网站
  • mail263企业邮箱登录入口许昌seo推广
  • 用易语言做抢购网站软件下载网站广告投放收费标准
  • .net制作网站开发教程北京百度推广电话
  • 上海比较好的网站制作公司seo关键词如何布局
  • 沧州哪家做网站好小程序开发一个多少钱啊
  • 永年做网站重庆关键词自动排名
  • wordpress编辑器保留word格式独立站seo建站系统
  • 网站建设制作设计珠海网页搜索引擎优化技术
  • 阿里云域名注册官网叫什么国内seo公司排名
  • 建设大型购物网站比较成功的网络营销案例
  • 服务器512m内存做网站全网seo优化电话
  • 学网站建设 去哪里网页制作的软件
  • 南京做网站公司地点首页关键词排名优化
  • 学做转手绘的网站哈尔滨seo和网络推广
  • 网站开发技术书籍网站销售怎么推广
  • 外贸网站索引页多手机百度