or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
明新科大
selenium
教學環境架設前言
由於資管系上電腦重開機會被還原,因此開發環境都無法保存下來。主機Windows 10系統有安裝vscode和virtualbox,因此將開發環境及程式碼都被在虛擬機中,並且在上課時將虛擬機導入至virtualbox,再使用vscode的remote-ssh連入虛擬機操作。
虛擬機部分
主系統
使用ubuntu 22.04桌面版製作,使用2CPU、4GB的記憶體及50GB的硬碟,網路卡使用NAT主機模式,只能和宿主機互通,虛擬機之間不互通。帳號密碼皆為
must
,IP為10.0.2.15
(此為VirtualBox的NAT主機連接預設值)。注意:此次VirtualBox主程式為配合學校主機,使用舊版6.1。
安裝套件
安裝基本套件
opensh-server
python3-pip
安裝chrome
使用firefox瀏覽器至網頁下載chrome瀏覽器並安裝。安裝完之後,輸入
google-chrome --version
查看chrome瀏覽器版本。(目前大版本看起來是113)- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →補充
如果是server版的ubuntu,如用
vagrant
產生的,不要直接指定chromedriver
,而是直接用apt
安裝,使用sudo apt install chromium-chromedriver
之後,就可以正常使用- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →安裝chromedriver
先下載,並且解壓縮之後,稍後複製到
/home/must/workspace/selenium/
目錄下。目前看起來大版本應該是113。下面是下載及解壓縮:- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →建立
python
環境指定port forwarding讓宿主機能存取
在VirtualBox的主介面中,在選擇該VM的狀態時按設定

「網路」->「介面卡1」->「NAT」->「進階」->「連接埠轉送」。

新增一筆規則,並分別填入

ssh
、TCP
,127.0.0.1
,5678
,10.0.2.15
,22
。之後按「確定」Visual Studio Code中的設定
安裝
Jupyter
擴充套件必須在教室本機先安裝Jupyter套件如下

在遠端也要裝,這樣才能選擇虛擬環境的核心

安裝
remote-ssh
擴充套件必須安裝此擴充套件,左下角才會出現可連接遠端主機的符號

按此連接至遠端主機

連接至遠端Linux主機
開啟遠端主機連線

選擇「Connect to host」

輸入

must@127.0.0.1:5678
此時會出現另一視窗,並且輸入密碼

must
。下面出現SSH和IP字樣時表示連線成功

開啟資料夾

選擇

/home/must/workspace/selenium
,再按下「確定」按鈕。需要再輸入一次密碼must
。將VM導出至
ova
可供學生使用及匯入導出
確定系統是關機狀態
右鍵選擇「匯出到OCI」

套用如下圖的設定,並選擇「下一步」

選擇「匯出」
開始匯出

匯入
匯入

選擇

must.ova
,下一步即可從Windows宿主機
ssh
至虛擬機must
must
虛擬機。ssh must@127.0.0.1 -p 5678
scrapy
部分安裝
scrapy
ssh
進入系統cd workspace/selenium
pipenv shell
scrapy
:pip install scrapy
scrapy
是否安裝成功如果出現下面畫面就是成功了

如果出現版本問題
如果出現SSL的問題

需要重新安裝一些套件
https://stackoverflow.com/questions/73859249/attributeerror-module-openssl-ssl-has-no-attribute-sslv3-method
安裝
docker
先
exit
退出再進入系統。如果出現下面畫面就是成功了。
