# Create Alchemy node server ,使用Python爬取相關資料 ###### tags: `開發者路徑` ###### 兌心科技 Insight Software : Create Alchemy node server,使用Python爬取相關資料 作者 : @dhsia17 # [Alchemy官方資料](https://docs.alchemy.com/alchemy/introduction/getting-started) **1. Create an Alchemy Apps** 選擇要使用的鏈,測試鏈種類或主鏈。 ![](https://i.imgur.com/jtNu35F.png) 在Apps中能看到相關資訊,取的測試代幣,設定Restrict Access 點擊View key 可見你的 API Key & HTTPS 後續編程時會使用到。 **2. Set up Alchemy as your Client** 要安裝 AlchemyWeb3.js,需要創建一個項目,導入到項目目錄以運行安裝。 執行以下命令(則一執行即可): With Yarn: ``` mkdir your-project-name //創建資料夾 cd your-project-name //進入資料夾 yarn add @alch/alchemy-web3 /下載Alchemy-web3套件 ``` With NPM: ``` mkdir your-project-name cd your-project-name npm init # (or npm init — yes) npm install @alch/alchemy-web3 ``` 您可能會收到warnings/errors,但無需擔心可以忽略! 要與 Alchemy 的節點基礎設施進行交互,繼續發送request。 從你的command line,創建一個新的專案目錄並 cd 進入它: ``` mkdir web3-example //可自行命名 cd web3-example //cd 進入資料夾 ``` 創建一個名為 index.js 的文件並添加以下內容: ``` async function main() { const { createAlchemyWeb3 } = require(“@alch/alchemy-web3”); const web3 = createAlchemyWeb3(“<api-key>"); const blockNumber = await web3.eth.getBlockNumber(); console.log(“The latest block number is “ + blockNumber); } main(); ``` Hint:您最終應該將 <api-key> 替換為您的 Alchemy API 密鑰。 再來,使用節點運行 ``` node index.js ``` 現在應該在控制台中看到最新的區塊編號! ``` The latest block number is 11043912 ``` 恭喜!您剛剛使用 Alchemy 編寫了您的第一個 web3 腳本,並將您的第一個請求發送到您的 Alchemy API 端點🎉 與您的 API 密鑰關聯的項目現在在儀表板上應如下所示: ![](https://i.imgur.com/cHPH2Eh.png) ![](https://i.imgur.com/jXey9FV.png) 成功與Alchemy的節點進行互動,再來就是使用爬蟲將網頁資訊截取下來。 待續... [原作者文章](https://medium.com/@dhsia17/create-alchemy-node-server-%E4%BD%BF%E7%94%A8python%E7%88%AC%E5%8F%96%E7%9B%B8%E9%97%9C%E8%B3%87%E6%96%99-3e65ff581c9c) # ###### About Insight Software ###### 兌心科技的專業橫跨多個領域,雲端架構、遊戲製作、區塊鏈技術、去中心化金融、醫療資訊和物聯網服務等,致力於成為企業Web2.0到Web3.0的領航員,提供**雲服務、線路、區塊鏈技術、金庫**等解決方案。 # ### 聯絡方式 兌心聯絡信箱 : service@insight-software.com ### 社群 [Website](https://www.insight-software.com/) [Medium](https://medium.com/insight-software) [Youtube](https://www.youtube.com/@insight-software) [Telegram](https://t.me/Insight_software) [Twitter](https://twitter.com/insightcapital_) [Instagram](https://www.instagram.com/insight.capital/) ![](https://i.imgur.com/MRSPRzH.png)