小伙伴們,這次推文講的是‘xpath‘,掌握起來不難的哦。而且,熟悉了這套路,別說pubmed,任何你能在瀏覽器實現(xiàn)的操作,都基本能通過selenium自動化進(jìn)行。
總代碼:
for i in range(51,56): driver.implicitly_wait(10) ActionChains(driver).move_to_element(driver.find_element_by_xpath('//*[@id="save-results-panel-trigger"]')).click().perform() Select(driver.find_element_by_xpath('//*[@id="save-action-selection"]')).select_by_visible_text("All results on this page") ActionChains(driver).move_to_element(driver.find_element_by_xpath('//*[@id="save-action-format"]')).click().perform() Select(driver.find_element_by_xpath('/html/body/main/div[1]/div/form/div[2]/select')).select_by_visible_text("CSV") ActionChains(driver).move_to_element(driver.find_element_by_xpath('//*[@id="save-action-panel-form"]/div[3]/button[1]')).click().perform() target =driver.find_element_by_xpath('//*[@id="search-results"]/section/div[3]/a/span') driver.execute_script("arguments[0].();", target) ActionChains(driver).move_to_element(driver.find_element_by_xpath('//*[@id="search-results"]/section/div[3]/a/span')).click().perform() ActionChains(driver).move_to_element(driver.find_element_by_xpath('//*[@id="search-page"]/div[12]/div/form/button')).click().perform() print('第'+str(i)+'頁下載成功') print('跳轉(zhuǎn)第'+str(i+1)+'頁面中') driver.quit() print('全部下載完畢,自動退出。')
文章標(biāo)題:Python自動化xpath實現(xiàn)自動搶票搶貨-創(chuàng)新互聯(lián)
新聞來源:http://aaarwkj.com/article46/ccjshg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、手機(jī)網(wǎng)站建設(shè)、App設(shè)計、微信公眾號、域名注冊、網(wǎng)站設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)