selenium-51job automated testing (CSS selectors select elements)

Log 51job,
http://www.51job.com

Enter the search keyword "python", Region Select "Hangzhou" (Note that if the location is already selected other areas, to get rid of),
search for the latest release positions, to fetch page information. Get the following information formatted

Python development engineers | Napa Technology Co., Ltd. in Hangzhou | Hangzhou | 0.8-1.6 Wan / month | 04-27
Python senior development engineer | in Zhejiang letter Technology Consulting Ltd. | Hangzhou | 1-1.5 Wan / month | 04-27
Advanced Python development engineer | computer Co., Ltd. in Hangzhou new thinking | Hangzhou - West Lake District | 1-1.5 Wan / month | 04-27

 

 

Import the webdriver Selenium from 
Driver = webdriver.Chrome (R & lt "D: \ for myself \ the Google \ the Chrome \ the Application \ 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') the Click ()
cityEles = driver.find_elements_by_css_selector ( '# work_position_click_center_right_list_000000 EM')
for City in cityEles:
cityName = city.text # print name of the city
selected = city.get_attribute ( 'class') == 'on' # judge
if (cityName == 'Hangzhou' and not the Selected) or \
(cityName = 'Hangzhou' and selected!): # city name Hangzhou not clicked or not the name of the city of Hangzhou was clicked
city.the Click ()
# save the city selection
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()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/iamshasha/p/11106376.html