一 安装
安装python3.7,Selenium库,然后查看谷歌浏览器的版本
在这个网址 https://chromedriver.chromium.org/downloads 去下载对应的ChromeDriver
下载下来之后,直接解压到python安装目录下的Scripts文件夹下,这个目录要加入环境变量中
二 实现
首先打开boss直聘的网站,找到搜索框的class name
python代码如下
from selenium import webdriver
url='https://www.zhipin.com/hangzhou/'
driver = webdriver.Chrome()
driver.get(url)
#找到输入框
searchEle = driver.find_element_by_class_name('ipt-search')
searchEle.send_keys('IOS')
#点击搜索按钮
btnSearch = driver.find_element_by_css_selector('button.btn.btn-search')
btnSearch.click()
#再去找到对应的职位信息
jobInfos = driver.find_elements_by_class_name('job-primary')
for info in jobInfos:
print( info.text)
这样就可以了,我们还可以继续找到它的下一页内容,将获取的信息写入csv文件中等,具体项目去看我的github
https://github.com/cytu0911/spider_boss.git
觉得还可以的话给我一个小星星