登录 51job ,
http://www.51job.com
输入搜索关键词 “python”, 地区选择 “杭州”(注意,如果所在地已经选中其他地区,要去掉),
搜索最新发布的职位, 抓取页面信息。 得到如下的格式化信息
Python开发工程师 | 杭州纳帕科技有限公司 | 杭州 | 0.8-1.6万/月 | 04-27
from selenium import webdriver
driver = webdriver.Chrome(r’F:\tools\webdriver\chromedriver_v73/chromedriver.exe’)
driver.implicitly_wait(10)
driver.get(‘http://www.51job.com’)
driver.find_element_by_id(‘kwdselectid’).send_keys(‘python’)
driver.find_element_by_id(‘work_position_input’).click()
cityEles = driver.find_elements_by_css_selector(’#work_position_click_center_right em’)
for one in cityEles:
cityName = one.text
selected = one.get_attribute(‘class’)
if cityName == u’杭州’:
if selected != ‘on’:
one.click()
driver.find_element_by_id(‘work_position_click_bottom_save’).click()
driver.find_element_by_css_selector(’.ush button’).click()
jobs = driver.find_elements_by_css_selector(’#resultList div.el’)
for job in jobs:
# 去掉第一行:标题行
if ‘title’ in job.get_attribute(‘class’):
continue
filelds = job.find_elements_by_tag_name('span')
strField = [fileld.text for fileld in filelds]
print (' | '.join(strField))
driver.quit()