|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
之前求职的时候,作为练习项目,爬了一下51job的招聘信息,为避免遗忘,现在记录一下.
爬取目标:
https://search.51job.com/list/000000,000000,0000,00,9,99,python爬虫,2,1.html
爬取字段:
先上最终爬取结果图示:
所用到的包:
- from lxml import etree
- import requests
- import time
- import pymysql
复制代码
相关元素的xpath定位:
- node_list = html.xpath("//div[@class='dw_table']")
- for node in node_list:
- '''
- Position 职位名称
- Company 公司名称
- Place 工作地区
- Wages 薪 资
- Time 发布时间
- Link 详情链接
- '''
- Position = node.xpath("./div/p/span/a/@title")
- Company = node.xpath("./div/span[@class='t2']/a/text()")
- Place = node.xpath("./div[@class='el']/span[2]/text()")
- Wages = node.xpath("./div[@class='el']/span[3]/text()")
- Time = node.xpath("./div[@class='el']/span[4]/text()")
- Link = node.xpath("./div/p/span/a/@href")
复制代码
文章中使用了Mysql数据库,如果想尝试运行代码,请先创建匹配的数据表:
- CREATE TABLE `51job` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `职位名称` text,
- `公司名称` text,
- `工作地区` text,
- `薪资` text,
- `发布时间` text,
- `详情页` text,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
复制代码
代码全文:
|
|