from selenium import webdriver
import time
options = webdriver.ChromeOptions()
optins.add_argument('--headless')
browser = webdriver.Chrome(options=options)
browser.get('http://maoyan.com/board/4')
def get_one_page()
dd_list = browser.find_elements_by_xpath('/html/body/div[4]/div/div/div[1]/dl/dd')
item = {}
for dd in dd_list:
item_list = dd.text.split('\n')
item['number'] = item_list[0]
item['name'] = item_list[1]
item['star'] = item_list[2]
item['time'] = item_list[3]
item['score'] = item_list[4]
print(item)
while True:
get_one_page()
try:
browser.find_element_by_link_text('下一页').click()
time.sleep(0.5)
except Exception as e:
print('抓取结束!')
browser.quit()
break