好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Python趣味爬蟲之用Python實現智慧校園一鍵評教

Python趣味爬蟲之用Python實現智慧校園一鍵評教

熱門標簽:河北防封卡電銷卡 手機網頁嵌入地圖標注位置 開封自動外呼系統怎么收費 400電話辦理哪種 開封語音外呼系統代理商 應電話機器人打電話違法嗎 地圖標注線上如何操作 電銷機器人的風險 天津電話機器人公司

一、安裝selenium庫

問題1:什么是selenium模塊?

  • 基于瀏覽器自動化的一個模塊。

 問題2:selenium模塊有什么作用呢?

  • 便捷地獲取網站中動態加載的數據
  • 便捷地實現模擬登錄

問題3:環境安裝

pip install selenium

二、下載一個瀏覽器的驅動程序(谷歌瀏覽器)

1.下載路徑

http://chromedriver.storage.googleapis.com/index.html

2.驅動程序和瀏覽器的映射關系(谷歌瀏覽器)

方法1:[不推薦]

在瀏覽器地址欄輸入:chrome://version/

  • 復制版本號,只取前三節

示例:版本號為90.0.4430.212,只需復制90.0.4430

  • 將復制的數字加到https://chromedriver.storage.googleapis.com/LATEST_RELEASE_后面

示例:https://chromedriver.storage.googleapis.com/LATEST_RELEASE_90.0.4430

博主嘗試了沒有成功

方法2:[推薦]

安裝webdriver-manager

pip install webdriver-manager

運行如下代碼

import time
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
# from webdriver_manager.microsoft import EdgeChromiumDriverManager
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
driver = webdriver.Chrome(ChromeDriverManager().install(),chrome_options=options)
# driver = webdriver.Edge(EdgeChromiumDriverManager().install())
driver.get('https://www.baidu.com/s?wd=123')
driver.close()

很簡單,省很多事

三、智慧校園評教實現

1.新建python文件導入相關包

from selenium import webdriver
import time
from lxml import etree

2. 使用selenium打開登錄頁面

# 實例化一個瀏覽器對象
bro = webdriver.Chrome(executable_path='./chromedriver')# 驅動程序所在路徑
# 讓瀏覽器發起一個指定url對應請求
bro.get('http://sso.cqcet.edu.cn/login')

3.錄入用戶名密碼,點擊登錄按鈕實現登錄

# 標簽定位
username_input = bro.find_element_by_id('username')
password_input = bro.find_element_by_id('password')
# 標簽交互
username_input.send_keys('**********')# 智慧校園賬號
password_input.send_keys('**********')# 智慧校園密碼
# 點擊登入按鈕
btn = bro.find_element_by_class_name('logon-btn')
btn.click()
time.sleep(2)# 停頓2s

4.進入教學評價系統

# 點擊學評教管理
bro.get('http://ossc.cqcet.edu.cn/xg/teaching/student/index/teach')
bro.find_element_by_class_name('nav-label').click()
time.sleep(2)
# 點擊學生評教
bro.get('http://ossc.cqcet.edu.cn/xg/teaching/student/xskb')
# page_source獲取瀏覽器當前頁面的頁面源碼數據
page_text = bro.page_source

5.實現評教操作

# 解析onclick里面的內容
tree = etree.HTML(page_text)
onclick_list = tree.xpath('//*[@id="bootstrap-table"]/tbody//a/@onclick')
print(onclick_list)
for onclick in onclick_list:
    if onclick[0:15] != "checkEvaluation":
        bro.execute_script(onclick)
        time.sleep(1)
        bro.find_element_by_class_name('layui-layer-btn0').click()
    time.sleep(1)

time.sleep(5)
bro.quit()

6.完成效果圖

四、附錄

以下為實現谷歌無頭瀏覽器和反檢測代碼,供參考

from selenium import webdriver
from time import sleep
#實現無可視化界面
from selenium.webdriver.chrome.options import Options
#實現規避檢測
from selenium.webdriver import ChromeOptions

#實現無可視化界面的操作
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')

#實現規避檢測
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])

#如何實現讓selenium規避被檢測到的風險
bro = webdriver.Chrome(executable_path='./chromedriver',chrome_options=chrome_options,options=option)

#無可視化界面(無頭瀏覽器) phantomJs
bro.get('https://www.baidu.com')

print(bro.page_source)
sleep(2)
bro.quit()

到此這篇關于Python趣味挑戰之用Python實現智慧校園一鍵評教的文章就介紹到這了,更多相關Python智慧校園一鍵評教內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • 快速一鍵生成Python爬蟲請求頭
  • 使用Python制作一個數據預處理小工具(多種操作一鍵完成)
  • 如何打包Python Web項目實現免安裝一鍵啟動的方法
  • 利用Python代碼實現一鍵摳背景功能
  • Ubuntu18.04 一鍵升級Python所有第三方包 及安裝python包的方法
  • Python一鍵安裝全部依賴包的方法
  • Python一鍵查找iOS項目中未使用的圖片、音頻、視頻資源
  • Python 一鍵獲取百度網盤提取碼的方法
  • Python 一鍵制作微信好友圖片墻的方法
  • Python字典循環添加一鍵多值的用法實例

標簽:山東 常州 成都 宿遷 蘭州 江蘇 六盤水 駐馬店

巨人網絡通訊聲明:本文標題《Python趣味爬蟲之用Python實現智慧校園一鍵評教》,本文關鍵詞  Python,趣味,爬蟲,之用,實現,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Python趣味爬蟲之用Python實現智慧校園一鍵評教》相關的同類信息!
  • 本頁收集關于Python趣味爬蟲之用Python實現智慧校園一鍵評教的相關信息資訊供網民參考!
  • 推薦文章