Hu Josh
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    2
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    明新科大`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) ![](https://hackmd.io/_uploads/ryOYdPoV2.png) **補充** *如果是server版的ubuntu,如用`vagrant`產生的,不要直接指定`chromedriver`,而是直接用`apt`安裝,使用`sudo apt install chromium-chromedriver`之後,就可以正常使用* ![](https://hackmd.io/_uploads/Sy9-5ufBh.png) **安裝chromedriver** 先下載,並且解壓縮之後,稍後複製到`/home/must/workspace/selenium/`目錄下。目前看起來大版本應該是113。下面是下載及解壓縮: ![](https://hackmd.io/_uploads/HyX_Ovi4h.png) ```shell= cd ~ wget https://chromedriver.storage.googleapis.com/113.0.5672.63/chromedriver_linux64.zip unzip chromedriver_linux64.zip ``` ### 建立`python`環境 ```shell= cd ~ mkdir workspace cd workspace mkdir selenium cd selenium pip install --upgrade pipenv pipenv install requests pipenv install selenium pipenv install Pillow pipenv install matplotlib pipenv install numpy pipenv install opencv-python pipenv install lxml mv ~/chromedriver . ``` ### 指定port forwarding讓宿主機能存取 1. 在VirtualBox的主介面中,在選擇該VM的狀態時按設定 ![](https://hackmd.io/_uploads/rkvWgBj42.png) 2. 「網路」->「介面卡1」->「NAT」->「進階」->「連接埠轉送」。 ![](https://hackmd.io/_uploads/rkIDgro42.png) 3. 新增一筆規則,並分別填入`ssh`、`TCP`, `127.0.0.1`, `5678`, `10.0.2.15`, `22`。之後按「確定」 ![](https://hackmd.io/_uploads/ByZ1brsN2.png) ## Visual Studio Code中的設定 ### 安裝`Jupyter`擴充套件 1. 必須在教室本機先安裝Jupyter套件如下 ![](https://hackmd.io/_uploads/ryeq-9E82.png) 2. 在遠端也要裝,這樣才能選擇虛擬環境的核心 ![](https://hackmd.io/_uploads/BJGxz5NIh.png) ### 安裝`remote-ssh`擴充套件 1. 必須安裝此擴充套件,左下角才會出現可連接遠端主機的符號 ![](https://hackmd.io/_uploads/S1dC-Ho43.png) 2. 按此連接至遠端主機 ![](https://hackmd.io/_uploads/H1_xzriE3.png) ### 連接至遠端Linux主機 1. 開啟遠端主機連線 ![](https://hackmd.io/_uploads/H1_xzriE3.png) 2. 選擇「Connect to host」 ![](https://hackmd.io/_uploads/SJdH7Hj4h.png) 3. 輸入`must@127.0.0.1:5678` ![](https://hackmd.io/_uploads/rJoDmHsEn.png) 4. 此時會出現另一視窗,並且輸入密碼`must`。 ![](https://hackmd.io/_uploads/BJaO7BjEh.png) 5. 下面出現SSH和IP字樣時表示連線成功 ![](https://hackmd.io/_uploads/rkbA7rjNh.png) 6. 開啟資料夾 ![](https://hackmd.io/_uploads/H1slEHo4h.png) 7. 選擇`/home/must/workspace/selenium`,再按下「確定」按鈕。需要再輸入一次密碼`must`。 ![](https://hackmd.io/_uploads/SyAGNHoNh.png) ![](https://hackmd.io/_uploads/BJaO7BjEh.png) ![](https://hackmd.io/_uploads/SyX9Ph1Bh.png) ## 將VM導出至`ova`可供學生使用及匯入 ### 導出 1. 確定系統是關機狀態 2. 右鍵選擇「匯出到OCI」 ![](https://hackmd.io/_uploads/SJQsELs4n.png) 3. 套用如下圖的設定,並選擇「下一步」 ![](https://hackmd.io/_uploads/H1b1S8sV2.png) 4. 選擇「匯出」 5. 開始匯出 ![](https://hackmd.io/_uploads/B1jSBLjN3.png) ### 匯入 1. 匯入 ![](https://hackmd.io/_uploads/HynDbPj4n.png) 2. 選擇`must.ova`,下一步即可 ![](https://hackmd.io/_uploads/S1PcZwsN2.png) ## 從Windows宿主機`ssh`至虛擬機`must` 1. 在VirtualBox中啟動`must`虛擬機。 2. 開啟cmd或Windows終端機,輸入`ssh must@127.0.0.1 -p 5678` 3. 輸入密碼後即可連入VM中的Linux。 ![](https://hackmd.io/_uploads/rytBfvoE2.png) ## `scrapy`部分 ### 安裝`scrapy` 1. 開機後`ssh`進入系統 2. 進入虛擬目錄`cd workspace/selenium` 3. 進入虛擬環境`pipenv shell` 4. 安裝`scrapy`:`pip install scrapy` 5. 測試`scrapy`是否安裝成功 ```shell= scrapy bench ``` 如果出現下面畫面就是成功了 ![](https://hackmd.io/_uploads/SJo7W_jHh.png) ### 如果出現版本問題 **如果出現SSL的問題** 需要重新安裝一些套件 ![](https://hackmd.io/_uploads/BkSLaiXL2.png) https://stackoverflow.com/questions/73859249/attributeerror-module-openssl-ssl-has-no-attribute-sslv3-method ### 安裝`docker` ```shell= sudo apt install curl sudo apt install tmux curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo usermod -aG docker $USER ``` 先`exit`退出再進入系統。 如果出現下面畫面就是成功了。 ![](https://hackmd.io/_uploads/HyRe1KoB3.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    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.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully