<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>William - 行銷技巧</title>
    <description>專門提供行銷技巧，掌握最新的 AI 新聞、網絡工具、新興趨勢</description>
    
    <link>https://affiliatewilliam.beehiiv.com/</link>
    <atom:link href="https://rss.beehiiv.com/feeds/fZsUm8fgiy.xml" rel="self"/>
    
    <lastBuildDate>Thu, 11 Jun 2026 19:57:02 +0000</lastBuildDate>
    <pubDate>Wed, 18 Sep 2024 14:40:04 +0000</pubDate>
    <atom:published>2024-09-18T14:40:04Z</atom:published>
    <atom:updated>2026-06-11T19:57:02Z</atom:updated>
    
      <category>Artificial Intelligence</category>
    <copyright>Copyright 2026, William - 行銷技巧</copyright>
    
    <image>
      <url>https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/publication/logo/08a50c85-8bfc-48f0-8e7e-d20247b715b0/Leonardo1-William-3D_Animation_Style_4k_create_a_30_year_old_asian_male_IT_profe.jpg</url>
      <title>William - 行銷技巧</title>
      <link>https://affiliatewilliam.beehiiv.com/</link>
    </image>
    
    <docs>https://www.rssboard.org/rss-specification</docs>
    <generator>beehiiv</generator>
    <language>en-us</language>
    <webMaster>support@beehiiv.com (Beehiiv Support)</webMaster>

      <item>
  <title>5 common email marketing mistakes even the pros make</title>
  <description></description>
      <enclosure url="https://images.unsplash.com/photo-1603791445824-0050bd436b6d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3w0ODM4NTF8MHwxfHNlYXJjaHw0fHxlbWFpbHxlbnwwfHx8fDE3MjY2NzAzNTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&amp;utm_source=beehiiv&amp;utm_medium=referral"/>
  <link>https://affiliatewilliam.beehiiv.com/p/5-common-email-marketing-mistakes-even-the-pros-make</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/5-common-email-marketing-mistakes-even-the-pros-make</guid>
  <pubDate>Wed, 18 Sep 2024 14:40:04 +0000</pubDate>
  <atom:published>2024-09-18T14:40:04Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:left;" id="5-common-email-marketing-mistakes-e">5 common email marketing mistakes even the pros make</h1><h2 class="heading" style="text-align:left;" id="what-most-creators-ignore-in-their-"><span style="color:rgb(19, 19, 19);font-family:Roboto, Arial, sans-serif;font-size:14px;">What most creators ignore in their email marketing</span></h2><p class="paragraph" style="text-align:left;">Sinem Günel increased her subscriber list by 30% and generated an extra $6,000 in revenue in just three months. And she did this by fixing a critical yet common issue with her automatic email introductions. Also known as her welcome sequence for new subscribers. The problem is most creators totally ignore this.</p><h2 class="heading" style="text-align:left;" id="how-are-you-welcoming-your-subscrib"><span style="color:rgb(19, 19, 19);font-family:Roboto, Arial, sans-serif;font-size:1.5rem;">How are you welcoming your subscribers?</span></h2><p class="paragraph" style="text-align:left;">There are some very key mistakes they make which lead to lower open rates, and as a result, fewer conversions for their business. So today we&#39;re going to reveal what these mistakes are, how you can avoid them, and what you can do differently to supercharge your own results. The first thing we&#39;re going to cover has caused so many creators to lose email subscribers as fast as they gain them, meaning that you can put in days of work and energy only to see very little results from your efforts.</p><p class="paragraph" style="text-align:left;">But before we dive deep into why this is and how to prevent it, we first need to understand the feature that helped Sinem Günel gain 4583 subscribers to her newsletter in just three months, and this feature is Recommendations. Recommendations allows you to grow your audience with collaboration, but it comes with its unique challenges, especially when welcoming new people in.</p><p class="paragraph" style="text-align:left;">If we think about traditional subscribers, they already know and trust you. They&#39;ve engaged with your content and they already kind of like you. On the flip side, subscribers that come in from Recommendations are most likely only hearing about you for the first time. And this is where the first mistake comes in: Welcoming your Recommended subscribers the same way that you do your traditional subscribers.</p><p class="paragraph" style="text-align:left;">If you make this mistake, you risk losing them before they even reach your second email. how did Sinem manage to overcome this issue? With one simple strategy, she created a unique welcome sequence for her Recommended subscribers, differentiating it from the one that she has set up for her traditional audience.</p><p class="paragraph" style="text-align:left;">This approach is crucial because it helps catch the Rrecommended subscribers up to speed with who you are and what value you can bring them. Here’s a quick idea on how you can get started with this unique welcome sequence. Email #1: Say hello and share some of your proudest evergreen content. Email #2: Introduce yourself and what you do.</p><h2 class="heading" style="text-align:left;" id="are-you-using-email-automations"><span style="color:rgb(19, 19, 19);font-family:Roboto, Arial, sans-serif;font-size:1.5rem;">Are you using email automations?</span></h2><p class="paragraph" style="text-align:left;">And email #3: Tell the story behind your brand and why you started your business. However, there is a crucial step closely tied to our goals that, if we overlook it, will ruin any chances of our carefully crafted welcome sequence reaching its intended audience. As creators, we all have ambitions. For me, it&#39;s important that I get to spend regular time with my wife and kids and friends, but I&#39;ve got my responsibilities here as a social media and YouTube strategist, and I&#39;m building up a brand on the side for work-from-home dads</p><p class="paragraph" style="text-align:left;">As content creators, it&#39;s not just life, you have to shoulder multiple jobs as well. You have to be a content creator, a product developer, a marketing strategist, a social media manager, a customer service representative, a networker, an educator, and so much more. So you might be thinking, how do we manage all these responsibilities? It&#39;s an impossible task to be everywhere at once.</p><p class="paragraph" style="text-align:left;">Which brings us to mistake number two: Overlooking the power of automations, or worse, setting them up incorrectly. Automations are like your digital clone, working around the clock without need for rest or sleep. But if we mess up, say, by bombarding our audience with too many emails we risk pushing our subscribers away.</p><p class="paragraph" style="text-align:left;">But when automations are done correctly, they can save us invaluable time and significantly increase engagement with our audience, Which is exactly what Sinem used to achieve her results. Sinem realized that every new subscriber coming through Recommendations is automatically associated with a form called ‘Creator Network’ in her ConvertKit account.</p><h2 class="heading" style="text-align:left;" id="how-soon-are-you-selling"><span style="color:rgb(19, 19, 19);font-family:Roboto, Arial, sans-serif;font-size:1.5rem;">How soon are you selling?</span></h2><p class="paragraph" style="text-align:left;">By connecting this form to a new automation, she ensured that everyone that came in as a Creator Network Recommendation received a tailored welcome sequence. Alright so let&#39;s get into what else might be causing people to hit the unsubscribe button before they even get to know you. So they&#39;ve joined your list through a Recommendation and they got your welcome email and they&#39;re learning a little bit about you.</p><p class="paragraph" style="text-align:left;">Maybe something is starting to brew there, but they&#39;ve still just met you. You haven&#39;t really taken them out to coffee yet, so to speak. So you wouldn&#39;t want to metaphorically go in for the kiss quite yet because that&#39;s way too forward. But it&#39;s the exact way that some marketers treat their subscribers.</p><p class="paragraph" style="text-align:left;">Think about how you normally interact with subscribers who&#39;ve discovered you through your other content. These people come in warm, familiar with who you are and what you stand for, ready to deepen that connection and probably buy something. But what happens when we drop a subscriber who has been Recommended to you into this very same pipeline? Suddenly the experience changes for a Recommended subscriber who might not be as familiar with your work, getting pitched with a product right away is going to feel abrupt and a bit awkward.</p><p class="paragraph" style="text-align:left;">It’s easy for us as content creators to forget that not all audiences are created equal and treating them as such leads to missed opportunities and mixed signals. And that leads us to mistake number three: Selling too quickly. The key here is to understand the unique journey of these subscribers. Unlike your regular audience, they might need a little bit more time to trust you and what you have to offer A useful strategy is to implement a temperature check within your sequence a way to gauge their engagement and readiness.</p><h2 class="heading" style="text-align:left;" id="how-are-you-using-your-data"><span style="color:rgb(19, 19, 19);font-family:Roboto, Arial, sans-serif;font-size:1.5rem;">How are you using your data?</span></h2><p class="paragraph" style="text-align:left;">For example, Jason Resnick helps creators with their email marketing and automations. He created something called the Quick Wins email. It&#39;s an email that contains three links and each one links to a resource that tackles a major issue the subscriber might be facing. If a subscriber clicks on any of these links, Jason tags them with “Click - Quick Win” and whatever the specific issue is that they clicked on and then they&#39;ll get an email sequence that pitches one of his offers.</p><p class="paragraph" style="text-align:left;">Basically, he doesn&#39;t send that sequence to someone until they&#39;ve shown interest by clicking. But imagine pouring your energy and passion into crafting the perfect nurture sequence, gathering data on your subscribers, tailoring every detail to keep them engaged, only to overlook a crucial step that renders all of your efforts pointless.</p><p class="paragraph" style="text-align:left;">So many people miss a chance to get this right, and by not doing this, they&#39;re throwing away an opportunity to have the maximum impact on their results. So picture this: You&#39;re super pumped to start binge watching this hilarious new comedy show that you found. it’s even starring an actor that you like, you really try to get your friend excited about this comedy gem.(06:24) But no dice. Your friend has really been into this mystery thriller series all caught up in the suspense and the dark plots and their mind is stuck on those mysteries and all that effort that you&#39;re putting in to switch their focus... turns out it&#39;s just kind of bugging them. and instead of bringing you closer over a shared show, it feels like you&#39;re pestering them.</p><p class="paragraph" style="text-align:left;">Do you see the misstep here? When we&#39;re not on the same page, even the best intentions can backfire. So what does this have to do with email? It&#39;s all about getting on the same page as your subscribers. Take Jason for example, by making one tiny change, he managed to take his open rate of Recommended subscribers from 27% to 56%.</p><p class="paragraph" style="text-align:left;">In other words, he got on the same page with his new subscribers and all it took was a change of his subject line from this... to this. You see he could tell from his results that the original subject line wasn&#39;t resonating with the audience. So he took note and made the right change. He also did a couple of things like moving links higher and making emails shorter to increase engagement.</p><p class="paragraph" style="text-align:left;">But this wouldn&#39;t have been the case if he made mistake number four: Ignoring the data. We think we know our followers, especially the loyal ones. But those new faces, they might see things differently. And we&#39;re missing out if we&#39;re not listening. So make sure you use your data to help you get on the same page as your new subscribers.</p><h2 class="heading" style="text-align:left;" id="when-do-you-send-your-emails"><span style="color:rgb(19, 19, 19);font-family:Roboto, Arial, sans-serif;font-size:1.5rem;">When do you send your emails?</span></h2><p class="paragraph" style="text-align:left;">But there&#39;s one more mistake which could make all of this hard work come toppling down. It&#39;s something that&#39;s really easy to fix. But when left un-noticed, it can cause so much damage to your subscriber count. Let&#39;s say you&#39;ve got your email sequence working like a well-oiled machine.</p><p class="paragraph" style="text-align:left;">Then you shoot out of broadcast and you&#39;re unsubscribes increase. Part of that is normal, the average unsubscribe rate is 0.5%. But if you&#39;re getting a lot of folks unsubscribing, here&#39;s what may be happening. Your subscribers start feeling like you&#39;re everywhere and not in a good way. If they&#39;re hearing from you too much, it can lead to unsubscribes or worse.</p><p class="paragraph" style="text-align:left;">The “This is spam” button. Setting up that automated sequence felt like a win, but then you want to send your normal weekly newsletter as a broadcast and you&#39;re like, “Uh oh, don&#39;t want to be that annoying friend. Am I sending too many emails? Did they get that automated sequence? Is it still too soon to send my normal weekly newsletter? On top of that?” So what&#39;s the move? While there isn&#39;t one standard that applies to all creators, as some creators are sending daily emails, others are sending weekly</p><p class="paragraph" style="text-align:left;">and some are sending less frequently than that. Here are a couple of things you can do Jason emails six times per week, and it&#39;s a mix of automated email sequences and broadcasts. He knows his sequence emails go out every day except Wednesday, Saturday and Sunday. So those are the days that he knows that he can send out his broadcasts.</p><p class="paragraph" style="text-align:left;">Kyle Adams, a creator growth manager here at ConvertKit who has his own newsletter, does something different Using visual automations, before someone enters a new sequence such as a welcome sequence, he adds the tag ‘Do Not Disturb’ to that subscriber. Then when he sends his broadcast, he sends it to everyone except anyone with the ‘Do Not Disturb’ tag.</p><p class="paragraph" style="text-align:left;">Whenever they finish the sequence, he has the visual automation remove the tag, so now they will receive his broadcasts. Doing either of these will help you avoid mistake number five, which is overwhelming your subscribers Create that breathing room between your automated sequences and your manual broadcasts.</p><p class="paragraph" style="text-align:left;">But overwhelming your own subscribers isn&#39;t the only thing that causes you to lose subscribers. There&#39;s actually an even bigger mistake email marketers make that&#39;s having a huge impact on their revenue. So check out our video Beginner vs Pro newsletters here to find out how to avoid it. We&#39;ll see you over there</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=baa6a7e9-40a0-40d3-8cb1-070c6946437e&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>Python - Spark != Pandas + Big Data</title>
  <description>Spark != Pandas + Big Data</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/cc311b41-4e8d-40f9-a2cb-b8728f88387b/aa3c8391-28b8-431d-a651-040b722fa5a8_1699x419.png" length="119491" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/python-spark-pandas-big-data</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/python-spark-pandas-big-data</guid>
  <pubDate>Mon, 12 Aug 2024 05:11:15 +0000</pubDate>
  <atom:published>2024-08-12T05:11:15Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Program Coding]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><p class="paragraph" style="text-align:left;"><b>Spark != Pandas + 大數據支持</b></p><p class="paragraph" style="text-align:left;">Pandas 和 Spark 操作相同類型的資料—表。然而，他們與之互動的方式卻截然不同。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/cc311b41-4e8d-40f9-a2cb-b8728f88387b/aa3c8391-28b8-431d-a651-040b722fa5a8_1699x419.png?t=1723439114"/></div><p class="paragraph" style="text-align:left;">然而，許多程式設計師經常將他們的學習從 Pandas 擴展到 Spark，假設類似的設計，這會導致效能瓶頸。</p><p class="paragraph" style="text-align:start;">今天我給大家舉個例子。</p><p class="paragraph" style="text-align:start;"><span style="color:rgb(54, 55, 55);font-family:-apple-system-ui-serif, ui-serif, Spectral, Georgia, serif;font-size:19px;">注意：如果您想要一個適合初學者的資源來學習 PySpark，我在這裡介紹了它：</span><span style="text-decoration:underline;"><b><a class="link" href="https://www.dailydoseofds.com/dont-stop-at-pandas-and-sklearn-get-started-with-spark-dataframes-and-big-data-ml-using-pyspark/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-spark-pandas-big-data" target="_blank" rel="noopener noreferrer nofollow" style="color: var(--color-fg-primary)">不要停留在 Pandas 和 Sklearn！使用 PySpark 開始使用 Spark DataFrames 和大數據 M</a></b></span><span style="color:rgb(54, 55, 55);font-family:-apple-system-ui-serif, ui-serif, Spectral, Georgia, serif;font-size:19px;"> L。</span></p><h2 class="heading" style="text-align:left;"><br>背景</h2><p class="paragraph" style="text-align:start;">Spark 中可以執行兩種類型的操作：</p><ol start="1"><li><p class="paragraph" style="text-align:left;"><b>轉換</b>：從現有的 DataFrame 建立新的 DataFrame。</p></li></ol><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F353713af-926d-4aeb-a560-8ca64f597ede_2624x409.png"/></div><ol start="2"><li><p class="paragraph" style="text-align:left;"><b>操作</b>：這些操作會觸發資料幀上轉換的執行。</p></li></ol><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe341e71f-885b-4ca7-ae4c-f3064ce1d7cd_3030x709.png"/></div><p class="paragraph" style="text-align:start;">為了給您更多上下文，Spark 使用操作，因為與 Pandas 等常見 DataFrame 庫不同，<b>Spark 轉換遵循惰性求值</b>。</p><p class="paragraph" style="text-align:start;">惰性評估意味著轉換不會立即產生結果。</p><p class="paragraph" style="text-align:start;">相反，計算會延後到觸發某個<b>操作為止</b>，例如：</p><ul><li><p class="paragraph" style="text-align:left;">查看/列印資料。</p></li><li><p class="paragraph" style="text-align:left;">將資料寫入儲存來源。</p></li><li><p class="paragraph" style="text-align:left;">將資料轉換為Python列表等。</p></li></ul><p class="paragraph" style="text-align:start;">透過延遲評估 Spark 轉換並僅在需要時執行它們，Spark 可以建立邏輯執行計劃並應用任何可能的最佳化。</p><p class="paragraph" style="text-align:start;">然而，這裡還有一個被忽視的警告，可能會導致冗餘計算。因此，如果處理不當，它會大幅減慢 Spark 程式的執行工作流程。</p><p class="paragraph" style="text-align:start;">讓我們更詳細地了解一下。</p><hr class="content_break"><h3 class="heading" style="text-align:start;">惰性評估問題</h3><p class="paragraph" style="text-align:start;">考慮從儲存中讀取 Spark DataFrame (A) 並對其執行轉換，這會產生另一個 DataFrame (B)。</p><p class="paragraph" style="text-align:start;">接下來，我們對 DataFrame B 執行兩個操作（計數行和查看資料），如下所示：</p><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68398015-8b57-4eee-b27f-d82e5a980ab3_2366x615.png"/></div><p class="paragraph" style="text-align:start;">這可以在 PySpark 中翻譯成以下程式碼：</p><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfed1a95-80b6-4d22-88b2-c65a33dbbe18_2668x1376.png"/></div><p class="paragraph" style="text-align:start;">現在，回想一下我們上面討論的內容：<i>操作觸發 Spark 轉換的執行</i>。</p><p class="paragraph" style="text-align:start;">在上面的程式碼中，第一個動作是<code>df_B.count()</code>，它觸發 CSV 讀取操作和過濾器轉換。</p><p class="paragraph" style="text-align:start;"><i>順便說一句，您可能已經注意到，執行方法與 Pandas 的工作方式有很大不同。它不提供惰性評估。因此，每個操作都會立即執行。</i></p><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F509bf07f-a8e6-4e1a-9f03-68169bdd30ce_2668x1376.png"/></div><p class="paragraph" style="text-align:start;">繼續，我們還有另一個動作：<code>df_B.show()</code>。此操作再次觸發 CSV 讀取操作和過濾器轉換。</p><p class="paragraph" style="text-align:start;">你看到問題了嗎？</p><p class="paragraph" style="text-align:start;"><b>我們正在讀取 CSV 檔案並執行相同的轉換兩次。</b></p><p class="paragraph" style="text-align:start;">顯然，在處理大型資料集時，這可能會導致嚴重的效能瓶頸。</p><hr class="content_break"><h3 class="heading" style="text-align:start;">解決方案</h3><p class="paragraph" style="text-align:start;">解決這個問題的常見方法是使用<b>快取</b>。</p><p class="paragraph" style="text-align:start;">顧名思義，它允許我們將 Spark 轉換的結果緩存<b>在記憶體中</b>以供以後使用。</p><p class="paragraph" style="text-align:start;">該<code>df.cache()</code>方法可以讓您做到這一點。</p><div class="blockquote"><blockquote class="blockquote__quote"><p class="paragraph" style="text-align:left;"><i>注意：除了 之外</i><code>df.cache()</code><i>，還有</i><code>df.persist()</code><i>method ，它為快取提供了更大的靈活性。但今天我們只討論</i><code>df.cache()</code>。</p><figcaption class="blockquote__byline"></figcaption></blockquote></div><p class="paragraph" style="text-align:start;">我們可以使用<code>df.cache()</code>以下方法：</p><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc5927c2-9d17-46c0-93f9-de72d48e1683_2576x1376.png"/></div><p class="paragraph" style="text-align:start;">在此程式碼中，第一個操作 ( <code>df_B.count()</code>) 觸發 CSV 讀取操作和過濾器轉換。</p><p class="paragraph" style="text-align:start;">然而，與我們之前討論的非快取演示相反，這次過濾器轉換的結果被緩存。</p><p class="paragraph" style="text-align:start;">繼續，第二個操作 ( <code>df_B.show()</code>) 使用這些快取的結果來顯示 的內容<code>df_B</code>。</p><p class="paragraph" style="text-align:start;">很容易理解，快取消除了冗餘操作，從而大大提高了運行時間。</p><hr class="content_break"><p class="paragraph" style="text-align:start;">請注意，該<code>df.cache()</code>方法將 DataFrame 緩存在記憶體中。</p><p class="paragraph" style="text-align:start;">因此，一旦不再需要緩存內存，建議將其釋放。我們可以使用<code>df.unpersist()</code>以下方法：</p><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffec807b3-dc1d-469c-b4a6-8b0e3e91055c_2576x1376.png"/></div><hr class="content_break"><p class="paragraph" style="text-align:start;">也就是說，Spark 是數據科學雇主最搶手的技能之一。將 Spark 添加到您的技能組合中將對您未來的數據科學職業生涯極其有價值。</p><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71a9b9f5-2781-4f04-ae71-1b2596fe5fc0_600x424.png"/></div><p class="paragraph" style="text-align:start;">我在 PySpark 上寫了一篇完整的適合初學者的深入探討（閱讀 102 分鐘）：<span style="text-decoration:underline;"><b><a class="link" href="https://www.dailydoseofds.com/dont-stop-at-pandas-and-sklearn-get-started-with-spark-dataframes-and-big-data-ml-using-pyspark/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-spark-pandas-big-data" target="_blank" rel="noopener noreferrer nofollow" style="color: var(--color-fg-primary)">不要停留在 Pandas 和 Sklearn！使用 PySpark 開始使用 Spark DataFrames 和大數據 M</a></b></span> L。</p><p class="paragraph" style="text-align:start;">如果您是完全的初學者並且以前從未使用過 Spark，那也沒關係。這篇文章涵蓋了一切。</p><p class="paragraph" style="text-align:start;">👉 接下來：還有哪些被忽視的 Spark 最佳化技術？</p><p class="paragraph" style="text-align:left;">感謝您閱讀數據科學的每日劑量！免費訂閱，每天學習有關 Python 和數據科學的新​​知識和深刻見解。此外，還可以獲得包含 320 多個技巧的免費資料科學 PDF（550 多頁）。</p><p class="paragraph" style="text-align:left;"><span style="color:var(--print_on_pop);">訂閱</span></p><hr class="content_break"><h3 class="heading" style="text-align:start;" id="mlds"><b>您是否對 ML/DS 中的資訊量感到不知所措？</b></h3><p class="paragraph" style="text-align:start;">我每週都會發布一些關於對您的 ML/DS 角色技能真正重要的主題的深入探討。</p><div class="image"><img alt="" class="image__image" style="" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa463bde0-2a7a-4758-8557-b6122ab4a4d9_2065x826.png"/></div></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=48bb3cbc-0a88-4672-a841-ed876bc410a8&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>5 分鐘教你用 Suno AI 生成媲美真人的歌曲</title>
  <description>Suno AI 快速生成媲美真人的歌曲</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/a1edb8cd-4ac9-4580-8ee4-8296706e0b38/image.png" length="112810" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/5-minutes-to-teach-you-how-to-use-suno-ai-to-generate-songs-that-are-as-good-as-real-people</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/5-minutes-to-teach-you-how-to-use-suno-ai-to-generate-songs-that-are-as-good-as-real-people</guid>
  <pubDate>Thu, 02 May 2024 05:53:00 +0000</pubDate>
  <atom:published>2024-05-02T05:53:00Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Ai]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:start;" id="5-suno-ai">5 分鐘教你用 Suno AI 生成媲美真人的歌曲</h1><p class="paragraph" style="text-align:left;">藝術一直被認為是人類獨特的領域。</p><p class="paragraph" style="text-align:start;">但現在我們不得不承認，無論繪畫、音樂還是影片，AI 已經越來越接近專家的水平。</p><p class="paragraph" style="text-align:start;">像筆者去年接觸 Suno 的時候，覺得他不過就是個玩具；但近期回鍋體驗後，我驚為天人！</p><p class="paragraph" style="text-align:start;">把生成的音樂放給朋友試聽，大家普遍無法辨別這是否為 AI 的作品。</p><p class="paragraph" style="text-align:start;">文章看到這，可能有不少人會感到緊張、焦慮。</p><p class="paragraph" style="text-align:start;">我認為這很正常，情緒在很多時候是驅動我們探索新世界的動力。</p><h1 class="heading" style="text-align:left;" id="suno"><b>▋ 註冊 Suno</b></h1><p class="paragraph" style="text-align:left;">Suno 官網: <span style="text-decoration:underline;"><a class="link" href="https://suno.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-suno-ai" target="_blank" rel="noopener noreferrer nofollow">https://suno.com/</a></span></p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*Koi9iF6VH8PLj-KiVoh2jA.png"/></div><p class="paragraph" style="text-align:left;">點擊左側「Create」選擇登入的方式。</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*srHqT1YX_9NL6lvPrgOmzA.png"/></div><h1 class="heading" style="text-align:left;"><b>▋ 簡易模式作曲</b></h1><p class="paragraph" style="text-align:left;">登入後每天可創作 10 首歌曲，且隔天會補充到 50 個 Credits。</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:1000/1*4ACGDC7jpO975r95MKH7EA.png"/></div><p class="paragraph" style="text-align:left;"><b>介面簡介</b>：</p><ul><li><p class="paragraph" style="text-align:left;"><b>Custom Mode</b>: 可以設計一首歌的細節參數，後面會做介紹。</p></li><li><p class="paragraph" style="text-align:left;"><b>Song Description</b>: 說明你想要創作的歌曲，支援中文輸入。</p></li><li><p class="paragraph" style="text-align:left;"><b>Instrumental</b>: 默認關閉，打開的話就只會生成不含人聲的純音樂。</p></li></ul><p class="paragraph" style="text-align:left;">我在「Song Description」輸入如下的 Prompt：「<code>創作一首熱血中文流行歌，描述一個體弱多病的男孩懷抱成為拳擊手的夢想，每天刻苦鍛鍊，儘管周圍所有人都不看好他，但他從未懷疑過自己，最終登上比賽舞台的故事</code>」</p><p class="paragraph" style="text-align:left;">寫好後點擊「Create」，稍等幾秒便創作完畢（每次會生成 2 首）。</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:1000/1*B3gm_LL8l31-qoU1rqnQ8w.png"/></div><p class="paragraph" style="text-align:left;">下面讓我們來試聽看看成果如何：</p><h1 class="heading" style="text-align:left;"><b>▋ 客製化作曲</b></h1><p class="paragraph" style="text-align:left;">如果你對生成的歌詞、曲風、樂器不滿意，你可以點擊「Reuse Prompt」來做客製化調整。</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:1000/1*NIoNTtgC-bZvgkFFk3W44w.png"/></div><p class="paragraph" style="text-align:left;">在上圖的「Lyrics」區塊，你會看到 Verse 1、Chorus 這類讓你心生恐懼的標籤（Meta Tags）。</p><p class="paragraph" style="text-align:left;">但別擔心，讓我簡單地向大家介紹一首完整的歌，通常會包含哪些標籤（Meta Tags），以及他們代表的意義：</p><ul><li><p class="paragraph" style="text-align:left;"><b>Intro</b>: 前奏，幫大家帶入歌曲氛圍。</p></li><li><p class="paragraph" style="text-align:left;"><b>Verse</b>1/2: 第一、二段歌曲，說明故事背景與情節。</p></li><li><p class="paragraph" style="text-align:left;"><b>Chorus</b>: 副歌，會多次重複，聽眾印象最深的段落。</p></li><li><p class="paragraph" style="text-align:left;"><b>Bridge</b>: 橋段，歌曲的轉折點，通常是為了帶來不同的旋律與情感。</p></li><li><p class="paragraph" style="text-align:left;"><b>Outro</b>: 尾奏，讓歌曲慢慢平靜下來收尾。</p></li></ul><p class="paragraph" style="text-align:left;">不過相信很多人看完後還是不知道怎麼操作，這時，就讓 ChatGPT 幫我們一把！</p><p class="paragraph" style="text-align:left;"></p><p class="paragraph" style="text-align:left;"></p><h1 class="heading" style="text-align:start;" id="chat-gpt"><b>▋ 請 ChatGPT 幫我們填詞</b></h1><p class="paragraph" style="text-align:start;">下面我把範例 Prompt 提供給大家參考，方括號 [] 內的描述可以依照自己需求調整：<br><span style="color:rgb(36, 36, 36);font-family:source-code-pro, Menlo, Monaco, Courier New, Courier, monospace;font-size:14px;">你是[世界頂尖的中文歌詞創作大師]，請你寫一首[充滿正能量]的歌詞。</span><br><span style="color:rgb(36, 36, 36);font-family:source-code-pro, Menlo, Monaco, Courier New, Courier, monospace;font-size:14px;">描述[一個男孩雖然天賦不佳，但靠著自己的努力，十年後終於踏上拳擊手的舞台，雖然從未贏過一場比賽，但他不後悔。他相信如果獲獎是強者的證明，那參賽就是對勇士的嘉許]。</span><br><span style="color:rgb(36, 36, 36);font-family:source-code-pro, Menlo, Monaco, Courier New, Courier, monospace;font-size:14px;">音樂的風格是[中文流行搖滾風]。</span><br><span style="color:rgb(36, 36, 36);font-family:source-code-pro, Menlo, Monaco, Courier New, Courier, monospace;font-size:14px;">詞曲的結構是[Verse1]-[Chorus]-[Verse2]-[Chorus]-[Bride]-[Chorus]-[Outro](結構兩旁要加上方號[]，並與上一段有一行空格)</span></p><p class="paragraph" style="text-align:start;">接下來直接把 ChatGPT 的結果貼到 Suno 上。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/a1edb8cd-4ac9-4580-8ee4-8296706e0b38/image.png?t=1714612734"/></div><p class="paragraph" style="text-align:left;"><span style="color:rgb(36, 36, 36);font-family:source-serif-pro, Georgia, Cambria, Times New Roman, Times, serif;font-size:20px;">我們來試聽看看 ChatGPT 與 Suno 合作的成果如何：</span><br></p><iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="true" class="youtube_embed" frameborder="0" height="100%" src="https://youtube.com/embed/o591EXpiqvM" width="100%"></iframe><p class="paragraph" style="text-align:left;"></p><h1 class="heading" style="text-align:left;"><b>▋ 接續未完成歌曲</b></h1><p class="paragraph" style="text-align:left;">目前 Suno 一次最多生成 2 分鐘的歌曲，所以當歌曲無法在 2 分內完成時，就需要透過 Extend 功能接續。</p><p class="paragraph" style="text-align:left;">在下圖我們選擇一個唱到一半的歌曲，點擊「Extend」。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ef207590-6885-44f1-bb07-25d6ee749011/image.png?t=1714627952"/></div><p class="paragraph" style="text-align:left;">如果很不幸 2 分鐘時剛好唱到一半，你就會需要在「Exetend from」把時間往前挪一點（ex: 1:50）；另外記得要移除先前已經唱過的歌詞（Lyrics），否則他會重頭唱。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/6ddfa72f-2c5d-4273-bc85-3e448157dd14/image.png?t=1714628447"/></div><p class="paragraph" style="text-align:left;">後半段生成完畢後，聽聽哪首比較符合你的期待，就可以對後半段的歌曲用「Get Whole Song」，把歌曲合併起來嚕～</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/6042f0d0-4c48-4a80-8453-31351a126c8e/image.png?t=1714628590"/></div><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/71b26b98-1f4a-482b-8b2f-53706115e87d/image.png?t=1714628770"/></div><p class="paragraph" style="text-align:left;"><span style="color:rgb(36, 36, 36);font-family:source-serif-pro, Georgia, Cambria, Times New Roman, Times, serif;font-size:20px;">如果 Extend 一次還是沒唱完，是可以多次 Extend 後再透過「Get Whole Song」合併的。</span><br></p><iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="true" class="youtube_embed" frameborder="0" height="100%" src="https://youtube.com/embed/j6qLUBHxolk" width="100%"></iframe><p class="paragraph" style="text-align:left;">儘管部分歌詞有咬字不清、漏字的問題，但我個人聽起來已經跟抖音上的歌曲差不多等級了。</p><p class="paragraph" style="text-align:start;">另外因為生成的音樂隨機性較高，所以如果想生成優秀的歌曲，就把他當成手遊抽 SSR 稀有角色吧</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=858b587e-50a1-4eb9-bcb1-923348bf089f&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>2024 年最適合開發者使用的 Python 套件</title>
  <description>什麼是 Python 套件?</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/8e270ec0-a2c9-4d1f-b949-788e589cf7be/Python_Packages.png" length="71567" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/the-best-python-packages-for-developers-to-use-in-2024</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/the-best-python-packages-for-developers-to-use-in-2024</guid>
  <pubDate>Tue, 09 Apr 2024 00:53:20 +0000</pubDate>
  <atom:published>2024-04-09T00:53:20Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:start;" id="2024-python"><b>2024 年最適合開發者使用的 Python 套件</b></h1><p class="paragraph" style="text-align:left;">您尋找最好的 Python 套件嗎？好吧，你來對地方了..！！在開始列出這個清單之前，讓我們先討論一下為什麼 Python 是最佳選擇。</p><h1 class="heading" style="text-align:left;" id="python"><b>什麼是 Python 套件？</b></h1><p class="paragraph" style="text-align:left;"><br>Python 套件是一種將相關 Python 模組組織到目錄層次結構中的方法。它有助於建立程式碼以實現更好的組織和可重複使用性。</p><p class="paragraph" style="text-align:start;">套件包含一個名為“<a class="link" href="http://init.py?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">init.py</a>”的特殊文件，它表示該目錄應被視為套件。 Python 套件使管理和分發相關模組集變得更加容易，從而提供了模組化且有組織的程式碼組織方法。</p><p class="paragraph" style="text-align:start;">為了有效地管理大量模組，必須有系統地將它們分組和排列。在 Python 中，套件是指包含一組模組的目錄。與在資料夾和子資料夾中組織電腦檔案的方式非常相似，Python 允許您將模組建置為套件和子套件以增強組織。</p><h1 class="heading" style="text-align:start;" id="python"><b>為什麼 Python 是最佳選擇？</b></h1><p class="paragraph" style="text-align:start;">眾所周知，Python 是可用來學習（和實現）機器學習技術的最佳語言之一，原因如下。</p><p class="paragraph" style="text-align:start;">以下是Python流行的幾個重要原因：</p><ul><li><p class="paragraph" style="text-align:left;">它擁有大量的圖書館。</p></li><li><p class="paragraph" style="text-align:left;">由於其簡單易用，它是初學者級別的程式語言。</p></li><li><p class="paragraph" style="text-align:left;">可移植性是Python 廣泛流行的另一個原因。</p></li><li><p class="paragraph" style="text-align:left;">Python的程式設計語法簡單易學，與C、Java、C++相比程度較高</p></li></ul><h1 class="heading" style="text-align:start;" id="python"><b>最好的 Python 套件：</b></h1><p class="paragraph" style="text-align:start;">以下是一些最好的 Python 套件和函式庫，它們將幫助您加快開發速度。</p><h2 class="heading" style="text-align:start;" id="num-py">NumPy</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*OJAK7BLjktoC_wh9.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://numpy.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/numpy/numpy?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> | <span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/numpy/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPI</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://github.com/KennethanCeyer/awesome-numpy?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Awesome</a></span></p><p class="paragraph" style="text-align:start;"><b>NumPy</b>是重要的 Python 包，在科學計算方面表現出色。它的功能擴展到處理聲波、處理影像和各種二進位函數。憑藉其豐富的功能集，NumPy 成為機器學習領域開發人員和專家的首選。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">高效能N維數組對象</p></li><li><p class="paragraph" style="text-align:left;">互動的</p></li><li><p class="paragraph" style="text-align:left;">通用資料的多維容器</p></li><li><p class="paragraph" style="text-align:left;">直覺的</p></li></ul><h2 class="heading" style="text-align:start;" id="tensor-flow">TensorFlow</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*ZpTG6d9icHVjGVoW.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://www.tensorflow.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/tensorflow/tensorflow?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> | <span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/tensorflow/?ref=hackernoon.com&utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPI</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://github.com/jtoy/awesome-tensorflow?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Awesome</a></span></p><p class="paragraph" style="text-align:start;"><b>TensorFlow</b>是專為進階數值運算而設計的最佳 Python 軟體套件之一。它用途廣泛，支援深度神經網路執行自然語言處理 (NLP)、循環神經網路、圖像識別、詞嵌入、手寫數字分類和求解偏微分方程 (PDE) 等任務。</p><p class="paragraph" style="text-align:start;">此外，TensorFlow 確保強大的架構支持，促進在不同平台（包括桌面、伺服器和行動裝置）上的直接部署。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">它針對速度進行了最佳化，利用 XLA 等技術進行快速線性代數運算。</p></li><li><p class="paragraph" style="text-align:left;">響應式構造</p></li><li><p class="paragraph" style="text-align:left;">靈活的</p></li><li><p class="paragraph" style="text-align:left;">易於訓練</p></li><li><p class="paragraph" style="text-align:left;">平行神經網路訓練</p></li><li><p class="paragraph" style="text-align:left;">大型社區</p></li><li><p class="paragraph" style="text-align:left;">開源</p></li></ul><h2 class="heading" style="text-align:start;" id="django-packages"><b>Django Packages</b></h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*HVKOLLX7wprRbHTl2IPDcQ.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://djangopackages.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/djangopackages/djangopackages?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> |</p><p class="paragraph" style="text-align:start;"><b>Django Packages</b>是 Django 專案的可重複使用應用程式、網站、工具等的目錄。在這裡您還可以找到可以幫助您完成專案的最新 Python 3 軟體包、框架和專案。</p><p class="paragraph" style="text-align:start;">談到 Django，建議使用 Django 管理模板，以避免在專案工作時遇到任何障礙。例如，您可以檢查<span style="text-decoration:underline;"><b><a class="link" href="https://themeselection.com/item/sneat-bootstrap-django-admin-template/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Sneat bootstrap 5 Django 管理範本</a></b></span>。它是為開發人員建立的最強大、最全面的 Bootstrap Django 管理儀表板模板！</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*2p28XDNYri9Pe0pPIprGRA.png"/></div><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;"><b>使用Django 5</b>構建</p></li><li><p class="paragraph" style="text-align:left;">使用 CSS 框架<b>Bootstrap 5</b></p></li><li><p class="paragraph" style="text-align:left;"><b>Docker</b>加快開發速度</p></li><li><p class="paragraph" style="text-align:left;"><b>垂直和水平</b>佈局</p></li><li><p class="paragraph" style="text-align:left;">預設、邊框和半暗主題</p></li><li><p class="paragraph" style="text-align:left;"><b>淺色、深色和系統</b>模式支持</p></li><li><p class="paragraph" style="text-align:left;">國際化/i18n 和 RTL 就緒</p></li><li><p class="paragraph" style="text-align:left;"><b>Python-Dotenv：</b>環境變數</p></li><li><p class="paragraph" style="text-align:left;"><span style="text-decoration:underline;"><a class="link" href="https://demos.themeselection.com/sneat-bootstrap-html-admin-template/documentation/django-init-configurations.html?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">主題配置</a></span>：輕鬆自訂我們的模板</p></li></ul><p class="paragraph" style="text-align:start;">此外，也提供 Asp NET Core MVC 儀表板版本</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*MUYNpT0lZnMvCMhwJY_rNg.png"/></div><h2 class="heading" style="text-align:start;" id="seaborn">Seaborn</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*o85alogq0ssPHUVa.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://seaborn.pydata.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/mwaskom/seaborn?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/seaborn/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPi</a></span></p><p class="paragraph" style="text-align:start;"><b>Seaborn</b>是另一個用於統計資料視覺化的 Python 套件。它是建構在 Matplotlib 之上。儘管它高度依賴 Matplotlib，但它提供了更用戶友好的介面和各種預先建構的統計圖。</p><p class="paragraph" style="text-align:start;">此外，Seaborn 能夠視覺化複雜的統計模型以及簡單的資料分佈。此外，它還可以非常輕鬆地創建準確且資訊豐富的資料視覺化。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">Seaborn 與 NumPy 和 Pandas 資料結構配合良好</p></li><li><p class="paragraph" style="text-align:left;">用於設定 matplotlib 圖形樣式的內建主題</p></li><li><p class="paragraph" style="text-align:left;">繪製統計時間序列數據</p></li><li><p class="paragraph" style="text-align:left;">擬合並可視化線性迴歸模型</p></li><li><p class="paragraph" style="text-align:left;">它帶有用於設定 Matplotlib 圖形樣式的內建主題</p></li><li><p class="paragraph" style="text-align:left;">可視化單變量和雙變量數據</p></li></ul><h2 class="heading" style="text-align:start;" id="requestshttp-for-humans"><b>REQUESTS：HTTP For Humans</b></h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*2BFnYoPP4ctlabVJuGqAuw.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://docs.python-requests.org/en/latest/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/psf/requests?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/requests/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPi</a></span></p><p class="paragraph" style="text-align:start;">Requests 可讓您極為輕鬆地傳送 HTTP/1.1 請求。無需手動將查詢字串新增至 URL 或對 POST 資料進行表單編碼。由於 urllib3，Keep-alive 和 HTTP 連線池是 100% 自動的。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">保持活動狀態和連線池</p></li><li><p class="paragraph" style="text-align:left;">國際網域名稱和 URL</p></li><li><p class="paragraph" style="text-align:left;">具有 Cookie 持久性的會話</p></li><li><p class="paragraph" style="text-align:left;">瀏覽器式 SSL 驗證</p></li><li><p class="paragraph" style="text-align:left;">自動內容解碼</p></li><li><p class="paragraph" style="text-align:left;">基本/摘要式身份驗證</p></li><li><p class="paragraph" style="text-align:left;">優雅的鍵/值 Cookie</p></li><li><p class="paragraph" style="text-align:left;">自動減壓</p></li><li><p class="paragraph" style="text-align:left;">Unicode 回應主體</p></li><li><p class="paragraph" style="text-align:left;">HTTP(S) 代理程式支援</p></li><li><p class="paragraph" style="text-align:left;">分段文件上傳</p></li></ul><h2 class="heading" style="text-align:start;" id="py-torch">PyTorch</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*kSs4_hV1o_227vuicDjUBA.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://pytorch.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/pytorch/pytorch?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> | <span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/torch/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPI</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://github.com/bharathgs/Awesome-pytorch-list?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Awesome</a></span></p><p class="paragraph" style="text-align:start;">PyTorch 透過使用者友好的前端、分散式培訓以及工具和庫生態系統實現快速、靈活的實驗和高效的生產。</p><p class="paragraph" style="text-align:start;">借助 TorchScript，PyTorch 在 Eager 模式下提供了易用性和靈活性，同時無縫過渡到圖形模式，以在 C++ 運行時環境中實現速度、最佳化和功能。</p><p class="paragraph" style="text-align:start;">此外，它還可以在 Linux、macOS 和 Windows 上運作良好。</p><h2 class="heading" style="text-align:start;" id="pandas">Pandas</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*x0sPJXvxwGT8S7JB0ZuSIw.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://pandas.pydata.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/pandas-dev/pandas/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> | <span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/pandas/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPI</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://github.com/tommyod/awesome-pandas?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Awesome</a></span></p><p class="paragraph" style="text-align:start;">Python Pandas 是一個開源函式庫，附帶多種用於資料操作和分析的工具。借助該庫，您可以從各種來源讀取數據，例如 SQL 資料庫、CSV、JSON 檔案和 Excel。</p><p class="paragraph" style="text-align:start;">它允許您僅使用一兩個命令來管理複雜的資料操作。此外，Python Pandas 還提供了多種用於組合資料、分組和過濾時間序列功能的內建方法。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">具有預設和自訂索引的快速且有效率的 DataFrame 物件。</p></li><li><p class="paragraph" style="text-align:left;">用於將資料從不同檔案格式載入到記憶體中資料物件的工具。</p></li><li><p class="paragraph" style="text-align:left;">資料對齊和缺失資料的綜合處理。</p></li><li><p class="paragraph" style="text-align:left;">重塑和旋轉數據集</p></li></ul><h2 class="heading" style="text-align:start;" id="matplotlib"><b>Matplotlib</b></h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:600/1*gw2NcnIYpiBlFy4le3pF5w.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><b><a class="link" href="https://matplotlib.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></b></span><b>| </b><span style="text-decoration:underline;"><a class="link" href="https://github.com/matplotlib/matplotlib?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>GitHub</b></a></span><b> | </b><span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/matplotlib/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>PyPI</b></a></span><b> |</b><span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/matplotlib/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>Awesome</b></a></span></p><p class="paragraph" style="text-align:start;">Matplotlib 是最常見的資料探索和視覺化函式庫。您可以使用它來建立基本圖形，例如線圖、直方圖、散佈圖、長條圖和圓餅圖。您還可以使用此庫創建動畫和互動式視覺化。 Matplotlib 是所有其他視覺化函式庫的基礎。</p><p class="paragraph" style="text-align:start;">該程式庫在格式化和樣式化繪圖方面提供了很大的靈活性。您可以自由選擇如何顯示標籤、網格、圖例等。但是，要建立複雜且視覺吸引力的繪圖，您需要編寫大量程式碼。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">創建出版品質的繪圖。</p></li><li><p class="paragraph" style="text-align:left;">製作可以縮放、平移和更新的互動式圖形。</p></li><li><p class="paragraph" style="text-align:left;">自訂視覺風格和佈局。</p></li><li><p class="paragraph" style="text-align:left;">匯出為多種文件格式。</p></li><li><p class="paragraph" style="text-align:left;">嵌入 JupyterLab 和圖形使用者介面。</p></li></ul><h2 class="heading" style="text-align:start;" id="scrapy">Scrapy</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*41hNClj0lom_zaBV.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://scrapy.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></span>| <span style="text-decoration:underline;"><a class="link" href="https://github.com/scrapy/scrapy?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> | <span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/Scrapy/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPI</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://github.com/croqaz/awesome-scrapy?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Awesome</a></span></p><p class="paragraph" style="text-align:start;">這是資料科學領域最好的 Python 套件之一。 Scrapy 也稱為蜘蛛機器人，負責爬行程式並從 Web 應用程式中擷取結構化資料。顧名思義，它是為抓取而設計的。此外，它是一個完整的框架，具有透過 API 收集資料並像爬蟲一樣運作的潛力。</p><p class="paragraph" style="text-align:start;">借助此 Python 包，您可以編寫程式碼、重複使用通用程式並為您的應用程式建立可擴展的爬蟲。此外，它是跨 Spider 類別創建的，其中包含爬蟲程式的指令。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">它會產生 JSON、CSV 和 XML 等格式的 Feed 匯出。</p></li><li><p class="paragraph" style="text-align:left;">Scrapy 是基於爬蟲，可以自動從網頁中提取資料。</p></li><li><p class="paragraph" style="text-align:left;">它內建支援透過 XPath 或 CSS 表達式從來源中選擇和提取資料。</p></li></ul><h2 class="heading" style="text-align:start;" id="sci-py"><b>SciPy</b></h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:672/1*tBuXeC2brBGIwVKQuirzJg.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><b><a class="link" href="https://www.scipy.org/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></b></span><b>| </b><span style="text-decoration:underline;"><a class="link" href="https://github.com/scipy/scipy?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>GitHub</b></a></span><b> | </b><span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/scipy/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>PyPI</b></a></span><b> |</b><span style="text-decoration:underline;"><a class="link" href="https://github.com/rossant/awesome-scientific-python?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>Awesome</b></a></span></p><p class="paragraph" style="text-align:start;">SciPy 是流行的機器學習 Python 套件之一。它一直是機器學習愛好者最喜歡的庫，因為它包含用於整合、最佳化、線性代數和統計的不同模組。</p><p class="paragraph" style="text-align:start;">SciPy 函式庫和 SciPy 堆疊之間存在差異。 SciPy 是構成 SciPy 堆疊的核心包之一。此外，SciPy 對於影像處理也非常有用。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">輕鬆處理數學運算。</p></li><li><p class="paragraph" style="text-align:left;">使用子模組提供有效的數值例程，例如數值積分和最佳化。</p></li><li><p class="paragraph" style="text-align:left;">支援信號處理。</p></li></ul><h2 class="heading" style="text-align:start;" id="keras">Keras</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*wwnExqe720PPHykHhs5Hqw.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><b><a class="link" href="https://keras.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">官方網站</a></b></span><b>| </b><span style="text-decoration:underline;"><a class="link" href="https://github.com/keras-team/keras?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>GitHub</b></a></span><b> | </b><span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/keras/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>PyPI</b></a></span><b> |</b><span style="text-decoration:underline;"><a class="link" href="https://github.com/markusschanta/awesome-keras?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow"><b>Awesome</b></a></span></p><p class="paragraph" style="text-align:start;">Keras 是為人類而非機器設計的 API。 Keras 遵循減少認知負荷的最佳實踐：它提供一致且簡單的 API，最大限度地減少常見用例所需的使用者操作數量，並提供清晰且可操作的錯誤訊息。 Keras 也高度重視製作優秀的文件和開發人員指南。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">它在CPU和GPU上都運行流暢。</p></li><li><p class="paragraph" style="text-align:left;">預標記資料集</p></li><li><p class="paragraph" style="text-align:left;">多種資料預處理方法</p></li><li><p class="paragraph" style="text-align:left;">模型評估</p></li><li><p class="paragraph" style="text-align:left;">模組化</p></li></ul><h2 class="heading" style="text-align:start;" id="theano">Theano</h2><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*Yy-8rrQ8uJ8PIJLZjrdLGA.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://github.com/Theano?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/Theano/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPi</a></span></p><p class="paragraph" style="text-align:start;">Theano 的核心是一個著名的科學計算庫，使您能夠定義、最佳化和評估處理多維數組的數學表達式。一些機器學習和人工智慧應用的基礎是重複計算棘手的數學表達式。</p><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">與 NumPy 緊密整合</p></li><li><p class="paragraph" style="text-align:left;">GPU 的透明使用</p></li><li><p class="paragraph" style="text-align:left;">高效率的符號區分</p></li><li><p class="paragraph" style="text-align:left;">速度和穩定性優化</p></li><li><p class="paragraph" style="text-align:left;">動態C程式碼生成</p></li><li><p class="paragraph" style="text-align:left;">廣泛的單元測試和自我驗證</p></li></ul><div class="blockquote"><blockquote class="blockquote__quote"><p class="paragraph" style="text-align:left;"><i><b>MILA 將停止開發 Theano：</b></i><i> </i><span style="text-decoration:underline;"><i><a class="link" href="https://groups.google.com/d/msg/theano-users/7Poq8BZutbY/rNCIfvAEAwAJ?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">https://groups.google.com/d/msg/theano-users/7Poq8BZutbY/rNCIfvAEAwAJ</a></i></span></p><figcaption class="blockquote__byline"></figcaption></blockquote></div><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*0uf3X46RTJI2MvzImeYVcA.png"/></div><h1 class="heading" style="text-align:start;" id="aesara-succeser-to-theano"><b>Aesara [Succeser to Theano]</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*gNNk-oGepNAzKbagoZi6xQ.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://github.com/aesara-devs/aesara?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> |<span style="text-decoration:underline;"><a class="link" href="https://pypi.org/project/aesara/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">PyPi</a></span></p><p class="paragraph" style="text-align:start;">Aesara 是 Python 中的一個快速、可破解的元張量庫，它允許您有效地定義、最佳化/重寫和評估涉及多維數組的數學表達式。它由不同的部分組成：</p><ul><li><p class="paragraph" style="text-align:left;">數組數學運算的符號表示</p></li><li><p class="paragraph" style="text-align:left;">速度和穩定性優化</p></li><li><p class="paragraph" style="text-align:left;">高效率的符號區分</p></li><li><p class="paragraph" style="text-align:left;">強大的重寫系統以程式設計方式修改您的模型</p></li><li><p class="paragraph" style="text-align:left;">可擴展後端 Aesara 目前可編譯為 C、Jax 和 Numba。</p></li></ul><p class="paragraph" style="text-align:start;"><b>特徵：</b></p><ul><li><p class="paragraph" style="text-align:left;">可破解的純 Python 程式碼庫</p></li><li><p class="paragraph" style="text-align:left;">可擴展的圖框架，適合快速開發自訂運算符和符號優化</p></li><li><p class="paragraph" style="text-align:left;">實現一個可擴展的圖形轉譯框架，目前透過 C、<span style="text-decoration:underline;"><a class="link" href="https://github.com/google/jax?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">JAX</a></span>和<span style="text-decoration:underline;"><a class="link" href="https://github.com/numba/numba?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Numba</a></span>提供編譯。</p></li><li><p class="paragraph" style="text-align:left;">基於最廣泛使用的 Python 張量庫之一：<span style="text-decoration:underline;"><a class="link" href="https://github.com/Theano/Theano?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">Theano</a></span>。</p></li></ul><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://github.com/aesara-devs/aesara?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-python" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></span> |PyPi</p><h1 class="heading" style="text-align:start;"><b>結論：</b></h1><p class="paragraph" style="text-align:start;">好吧，我們在這裡討論了 Python 開發人員可以用來加快開發過程的一些最佳 Python 套件。</p><p class="paragraph" style="text-align:start;">眾所周知，Python生態系無論是貢獻或使用量都非常龐大。我們討論了在 ML 的所有主要領域中最常用於機器學習的 Python 套件和函式庫，從資料操作階段到深度學習、自然語言處理，甚至視覺化。</p><p class="paragraph" style="text-align:start;">此外，Python 還提供了一組多樣化的軟體包，這些軟體包不僅增強了其功能，還展示了人們可以執行的任務的廣度和深度。在這裡我們只提到了其中的幾個。</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=8d23bd28-16bf-4896-8e1f-d57f3982625f&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>讓你寫出更安全的 Dockerfile</title>
  <description>Docker file 幾個小技巧,讓你寫出更安全的Container.</description>
  <link>https://affiliatewilliam.beehiiv.com/p/docker-file-allows-you-to-write-more-safely</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/docker-file-allows-you-to-write-more-safely</guid>
  <pubDate>Fri, 05 Apr 2024 07:46:32 +0000</pubDate>
  <atom:published>2024-04-05T07:46:32Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Ai]]></category>
    <category><![CDATA[Program Coding]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:start;" id="dockerfile"><b>讓你寫出更安全的 Dockerfile</b></h1><p class="paragraph" style="text-align:left;">自從進入大容器時代後，Docker、K8s 已經逐漸成為開發、測試及部署時不可或缺的工具，如果突然叫我不要用 Docker，那我可能什麼都做不了，但也因為這樣，跟容器有關的攻擊越來越普遍，因此容器的安全性也越來越重要</p><p class="paragraph" style="text-align:start;">而<b>想要從零開始建出一個容器，第一步就是要寫 Dockerfile 把你的應用包裝成 Docker image</b>。關於怎麼產生出盡量小的 image 已經很多人寫過了，所以今天想要跟大家分享的是想要寫出一個安全的 Dockerfile，有哪些該注意的地方。</p><h1 class="heading" style="text-align:start;" id="stable-lts-base-image"><b>使用 stable 或 LTS 的 base image</b></h1><p class="paragraph" style="text-align:start;">很多人在寫 Dockerfile 並不會特別指定 base image 的版本（就懶啊，我懂 XD），譬如說想要包一個 Node API server，就直接寫 <code>FROM node</code> 或是 <code>FROM node:latest</code></p><div class="codeblock"><pre><code># Bad
FROM node

WORKDIR /app
COPY . .

RUN npm install
RUN npm run test</code></pre></div><p class="paragraph" style="text-align:left;"><a class="link" href="https://gist.github.com/LarryLuTW/ca82c3291979862c3b2b0ebe8e551721?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#file-bad-dockerfile" target="_blank" rel="noopener noreferrer nofollow">bad.Dockerfile </a><span style="color:rgb(101, 109, 118);font-family:-apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;font-size:12px;">hosted with ❤ by </span><a class="link" href="https://github.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></p><p class="paragraph" style="text-align:left;">但這樣可能會在哪次 <b>build image 時就意外從 Node 14 升到 Node 16，導致部分功能直接壞掉</b>。而且最新版本的 Node 可能有一些不為人知的 bug，需要有一些勇者去幫忙踩坑，所以除非是自己的 Side Project 想要玩玩看最新的 feature，否則<b>直接把最新版本的 Node 用在 production 並不是個好作法</b></p><p class="paragraph" style="text-align:start;">比較好的方式是<b>先看看 Node 的 LTS（Long-Term Support） 版本是多少</b>，像我在寫文章的當下是 <code>v14.17.5</code>，那就選擇 <code>node:14</code> 或是 <code>node:14.17</code> 作為 base image。</p><div class="codeblock"><pre><code># Good
FROM node:14

WORKDIR /app
COPY . .

RUN npm install
RUN npm run test</code></pre></div><p class="paragraph" style="text-align:start;">這樣做一來是可以把版號固定在 Node 14、確保不會有大變動，二來是 LTS 的版本都會不斷推出 security fix，因此如果哪天 Node 更新到 <code>v14.17.10</code>，那些 security fix 也會在部署時被加進的 API server，<b>我們只要坐等更新就好了</b></p><h1 class="heading" style="text-align:start;"><b>安裝套件時要指定版本</b></h1><p class="paragraph" style="text-align:start;">這點跟上面提到的不要用 latest image 有些類似，不管你是用 <code>apt-get install</code> 安裝 CLI 工具、用 <code>npm install</code> 裝函式庫、還是用 curl/wget 把東西下載回來編譯，都要<b>盡量確保每次下載到的東西是一樣的</b></p><p class="paragraph" style="text-align:start;">譬如在用 apt-get 安裝 nginx 時就可以透過 <code>apt-get install nginx=1.14.0</code> 來下載指定版本（有點麻煩對吧，我也覺得XD），而 npm、pip 這類的語言套件管理工具則是看官方推薦什麼方法，像 npm 就是用 <code>package-lock.json</code> 來鎖定套件的版本、pip 的話則是先跑 <code>pip freeze &gt; requirements.txt</code> 把套件的版本凍起來，等要安裝時再跑 <code>pip install -r requirements.txt</code> 把原本的套件裝回來。</p><div class="codeblock"><pre><code># Good
FROM ubuntu:20.04

RUN apt-get update
RUN apt-get install nginx=1.14.0 python=2.7.15 nodejs=12.18.2</code></pre></div><p class="paragraph" style="text-align:start;">雖然把套件版本的鎖定之後可以省下很多麻煩，<b>但也不能一直鎖在那都不更新，所以記得偶爾去檢查一下版本是不是太舊了</b>，如果太舊再手動把版號升上去就好了～</p><h1 class="heading" style="text-align:start;" id="copy"><b>只 COPY 需要的東西</b></h1><p class="paragraph" style="text-align:start;">平常在寫 Dockerfile 時，有些人為了一時方便，會直接用 <code>COPY . /app</code> 把整個專案資料夾複製到 container 的 <code>/app</code> 資料夾內。這樣不用動太多腦筋，在 container 裡面也可以直接存取到所有檔案，但這樣的做法可以說是糟透了。</p><div class="codeblock"><pre><code>FROM node:14
WORKDIR /app

# Very BAD
COPY . .

RUN npm install
RUN npm run test
CMD [&quot;node&quot;, &quot;index.js&quot;]</code></pre></div><p class="paragraph" style="text-align:start;">首先是這樣會讓 image 變得很肥（連 <code>node_modules</code> 都進去了能不肥嗎XD），而且一不小心就會把 <code>.envrc</code> 這類敏感資料一起放進去，<b>如果哪天這個 image 被駭客拿到，裡面的 AWS 憑證、資料庫密碼等等超機密資料就會直接外洩出去</b>，哪天突然被刪庫也是有可能的</p><p class="paragraph" style="text-align:start;">為了避免這種事情發生，<b>在 build image 時應該只把需要的東西複製進去</b>，譬如說你馬上就要跑 <code>npm install</code>，這才把 <code>package.json</code> 跟 <code>package-lock.json</code> 放進去，<b>而程式碼也是把真的會跑到的那些放進去就好。</b></p><div class="codeblock"><pre><code>FROM node:14
WORKDIR /app

# Good
COPY package.json package-lock.json ./
RUN npm install

# Good
COPY src/ index.js ./
RUN npm run test
CMD [&quot;node&quot;, &quot;index.js&quot;]</code></pre></div><p class="paragraph" style="text-align:left;">而且這樣還有另外一個好處，就是如果你改了 <code>src</code> 裡面的程式碼，但沒有安裝新的 package（開發時大部分都是這樣吧～），<b>因為 Docker 會自動做 cache，所以就不需要重新跑一次 npm install</b>，會直接從第 10 行的 <code>npm run test</code> 開始跑，因此可以大幅縮減需要等待的時間</p><h1 class="heading" style="text-align:start;" id="multistage-build"><b>用 multi-stage build 捨棄不需要的檔案</b></h1><p class="paragraph" style="text-align:start;">這跟上一點有點類似，<b>簡單來說就是不要留任何不需要的東西在 image 裡面（</b>沒用的東西都給我滾），即便那是 build image 過程中產生的東西也是一樣</p><p class="paragraph" style="text-align:start;">譬如說原本 Go API server 的 Dockerfile 可能長這樣，因為要在 build image 時編譯出執行檔，所以第 5 行的 <code>COPY *.go</code> 是一定要的，沒有他們就無法進行編譯。</p><div class="codeblock"><pre><code>FROM golang:1.17

WORKDIR /app

COPY *.go go.mod go.sum ./
RUN go build -o main

CMD [&quot;./main&quot;]</code></pre></div><p class="paragraph" style="text-align:left;"><b>但說真的一旦編譯出執行檔之後，那些 Go 程式碼就用不到了，</b>所以應該來個爽快的過河拆橋，用 multi-stage build 把編譯完的執行檔保留下來就好，程式碼什麼的就直接拜拜</p><p class="paragraph" style="text-align:start;">像下面這個這個 Dockerfile 經過 multi-stage build 後 image 裡面就只有 <code>/app/main</code> 這個編譯好的執行檔，沒有任何程式碼以及 Go 的編譯器，非常的存粹。</p><div class="codeblock"><pre><code># compile stage
FROM golang:1.17 as compile-env
WORKDIR /app
COPY *.go go.mod go.sum ./
RUN go build -o main

# final stage
FROM gcr.io/distroless/base
COPY --from=compile-env /app/main /app
CMD [&quot;/app/main&quot;]</code></pre></div><p class="paragraph" style="text-align:left;">那這樣有什麼好處呢？除了 image 可以變小很多之外，<b>即便 image 被駭客拿到了，程式碼也不會外流出去（有很多攻擊都是拿到程式碼後從裡面找到漏洞）</b>，因此只保留執行檔可以提高安全性</p><p class="paragraph" style="text-align:start;">除此之外，<b>因為環境越複雜就越可能有沒發現的漏洞</b>，而把 base image 從原本的 <code>golang:1.17</code> 換成 Google 提供的 <span style="text-decoration:underline;"><a class="link" href="https://github.com/GoogleContainerTools/distroless?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile" target="_blank" rel="noopener noreferrer nofollow">distroless image</a></span> 剛好可以大幅減少環境的複雜度（distroless 幾乎沒裝什麼東西，連 shell 都沒有），也就可以提高安全性</p><h1 class="heading" style="text-align:start;" id="hardcode-dockerfile"><b>不要把敏感資料 hardcode 在 Dockerfile 裡面</b></h1><p class="paragraph" style="text-align:start;">我想這已經是常識等級的安全知識了，<b>因為直接把敏感資料用 </b><code>ENV</code><b> 寫在 Dockerfile 裡會讓駭客輕易拿到</b>（只要拿到 image 就可以了），所以絕對不要想不開把資料庫或任何的帳號密碼寫在裡面，<code>ENV</code> 頂多用來設定時區或是 <code>NODE_ENV</code> 這種被看光也不會出事的變數就好，不然哪天資料被偷走真的會哭出來。</p><div class="codeblock"><pre><code>FROM node:14

ENV TZ=Asia/Taipei
ENV NODE_ENV=production

# Very Bad
ENV PG_HOST=test.postgresql.com
ENV PG_USER=thisIsmyUserName
ENV PG_PASS=mySecretPa55w0rd
ENV PG_DBNAME=projectName

COPY . .
RUN npm install
CMD [&quot;node&quot;, &quot;index.js&quot;]</code></pre></div><p class="paragraph" style="text-align:left;">如果說 ENV 不能放敏感資料，那這些資料究竟要怎麼被加進環境變數呢？</p><p class="paragraph" style="text-align:start;">答案就是在 <code>docker run</code> 時加上 <code>--env</code> 或是<code> --env-file</code> <span style="text-decoration:underline;"><a class="link" href="https://docs.docker.com/engine/reference/commandline/run/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#set-environment-variables--e---env---env-file" target="_blank" rel="noopener noreferrer nofollow">把環境變數塞進去</a></span>；如果是用 docker-compose 的話，則是<span style="text-decoration:underline;"><a class="link" href="https://docs.docker.com/compose/environment-variables/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#set-environment-variables-in-containers" target="_blank" rel="noopener noreferrer nofollow">把那些資料寫進 </a></span><code>docker-compose.yml</code><span style="text-decoration:underline;"><a class="link" href="https://docs.docker.com/compose/environment-variables/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#set-environment-variables-in-containers" target="_blank" rel="noopener noreferrer nofollow"> 的 environment 裡面</a></span>，<b>這樣 container 啟動時就會讀到這些變數，而且即便 image 被偷走也不用擔心資料外洩</b></p><h1 class="heading" style="text-align:start;"><b>弱點掃描</b></h1><p class="paragraph" style="text-align:start;">可以做的事情都做了之後，最後就是要來用工具來做弱點掃描了。因為做弱描的工具還滿多的，這邊就介紹已經被 Docker 加進 CLI 的 Snyk，他可以把你的環境、安裝的套件丟到他們資料庫去做搜尋，看有哪些潛在的危險</p><p class="paragraph" style="text-align:start;">譬如說我手邊有幾個多年前用 Node.js 寫的 express server，Dockerfile 長這樣（看到 9.2.0 就知道真的是多年前XD，現在都已經 Node 16 了）。</p><div class="codeblock"><pre><code>FROM node:9.2.0

COPY index.js package.json /app/
WORKDIR /app
RUN npm install &amp;&amp; npm cache clean --force

CMD node index.js</code></pre></div><p class="paragraph" style="text-align:left;">先用 <code>docker build . -t app</code> 把 image 建出來後，接著就下 <code>docker scan app</code> 對他做掃描。因為我用的是古早古早以前的 <code>node:9.2.0</code>，所以光 Base Image 的部分掃出來就有 1039 個漏洞，而且其中 99 是屬於 critical 等級的，嚇都嚇死</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*FnBbkmBYd8QA6dt0M-tJIA.png"/></div><p class="paragraph" style="text-align:start;">除了告訴你有多少漏洞之外，他還會把每個漏洞給列出來（有興趣可以去讀一下那些漏洞的報告，其實都不長），並且告訴你那些漏洞分別在哪些版本修掉了</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*4I7j2coYVQwWZY6wqUSeFQ.png"/></div><p class="paragraph" style="text-align:start;">如果懶得看那些漏洞的話，也可以直接滑到最底下看他給你的建議，譬如這邊他就建議把 base image 升級到 <code>node:16.7.0</code>，若是不一定要 full image 的話，那 <code>node:16-bullseye-slim</code> 也是不錯的選項，<b>因為安裝的東西更少，所以漏洞自然也更少。</b></p><div class="blockquote"><blockquote class="blockquote__quote"><p class="paragraph" style="text-align:left;"><i>Debian bullseye 是今年八月剛發佈的版本，可能比較不穩定</i></p><figcaption class="blockquote__byline"></figcaption></blockquote></div><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*f3nHZovlPf1kwy0HP1LiqA.png"/></div><h1 class="heading" style="text-align:start;"><b>總結</b></h1><p class="paragraph" style="text-align:start;">今天介紹了一些在寫 Dockerfile 時的注意事項，雖然很多都是小地方，但畢竟魔鬼藏在細節裡，想要讓你的 Docker image 更安全，那就連這些小細節都不能放過。</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=26ee24ee-e085-45a7-8f80-918c1b787a06&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>讓你寫出更安全的 Dockerfile</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2024/04/1FnBbkmBYd8QA6dt0M-tJIA-nVXlrs-150x150.png&quot; class=&quot;attachment-thu</description>
  <link>https://affiliatewilliam.beehiiv.com/p/e8-ae-93-e4-bd-a0-e5-af-ab-e5-87-ba-e6-9b-b4-e5-ae-89-e5-85-a8-e7-9a-84-dockerfile</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/e8-ae-93-e4-bd-a0-e5-af-ab-e5-87-ba-e6-9b-b4-e5-ae-89-e5-85-a8-e7-9a-84-dockerfile</guid>
  <pubDate>Fri, 05 Apr 2024 07:46:32 +0000</pubDate>
  <atom:published>2024-04-05T07:46:32Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/863a7bc2-6d79-47ec-bf92-775174a9e305/1FnBbkmBYd8QA6dt0M-tJIA-nVXlrs-150x150.png?t=1714610063"/></div><h1 class="heading" style="text-align:left;">讓你寫出更安全的 Dockerfile</h1><p class="paragraph" style="text-align:left;">自從進入大容器時代後，Docker、K8s 已經逐漸成為開發、測試及部署時不可或缺的工具，如果突然叫我不要用 Docker，那我可能什麼都做不了，但也因為這樣，跟容器有關的攻擊越來越普遍，因此容器的安全性也越來越重要</p><p class="paragraph" style="text-align:left;">而想要從零開始建出一個容器，第一步就是要寫 Dockerfile 把你的應用包裝成 Docker image。關於怎麼產生出盡量小的 image 已經很多人寫過了，所以今天想要跟大家分享的是想要寫出一個安全的 Dockerfile，有哪些該注意的地方。</p><h1 class="heading" style="text-align:left;">使用 stable 或 LTS 的 base image</h1><p class="paragraph" style="text-align:left;">很多人在寫 Dockerfile 並不會特別指定 base image 的版本（就懶啊，我懂 XD），譬如說想要包一個 Node API server，就直接寫 FROM node 或是 FROM node:latest</p><p class="paragraph" style="text-align:left;"># BadFROM node</p><p class="paragraph" style="text-align:left;">WORKDIR /appCOPY . .</p><p class="paragraph" style="text-align:left;">RUN npm installRUN npm run test</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://gist.github.com/LarryLuTW/ca82c3291979862c3b2b0ebe8e551721?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#file-bad-dockerfile" target="_blank" rel="noopener noreferrer nofollow">bad.Dockerfile </a>hosted with by <a class="link" href="https://github.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile" target="_blank" rel="noopener noreferrer nofollow">GitHub</a></p><p class="paragraph" style="text-align:left;">但這樣可能會在哪次 build image 時就意外從 Node 14 升到 Node 16，導致部分功能直接壞掉。而且最新版本的 Node 可能有一些不為人知的 bug，需要有一些勇者去幫忙踩坑，所以除非是自己的 Side Project 想要玩玩看最新的 feature，否則直接把最新版本的 Node 用在 production 並不是個好作法</p><p class="paragraph" style="text-align:left;">比較好的方式是先看看 Node 的 LTS（Long-Term Support） 版本是多少，像我在寫文章的當下是 v14.17.5，那就選擇 node:14 或是 node:14.17 作為 base image。</p><p class="paragraph" style="text-align:left;"># GoodFROM node:14</p><p class="paragraph" style="text-align:left;">WORKDIR /appCOPY . .</p><p class="paragraph" style="text-align:left;">RUN npm installRUN npm run test</p><p class="paragraph" style="text-align:left;">這樣做一來是可以把版號固定在 Node 14、確保不會有大變動，二來是 LTS 的版本都會不斷推出 security fix，因此如果哪天 Node 更新到 v14.17.10，那些 security fix 也會在部署時被加進的 API server，我們只要坐等更新就好了</p><h1 class="heading" style="text-align:left;">安裝套件時要指定版本</h1><p class="paragraph" style="text-align:left;">這點跟上面提到的不要用 latest image 有些類似，不管你是用 apt-get install 安裝 CLI 工具、用 npm install 裝函式庫、還是用 curl/wget 把東西下載回來編譯，都要盡量確保每次下載到的東西是一樣的</p><p class="paragraph" style="text-align:left;">譬如在用 apt-get 安裝 nginx 時就可以透過 apt-get install nginx=1.14.0 來下載指定版本（有點麻煩對吧，我也覺得XD），而 npm、pip 這類的語言套件管理工具則是看官方推薦什麼方法，像 npm 就是用 package-lock.json 來鎖定套件的版本、pip 的話則是先跑 pip freeze &gt; requirements.txt 把套件的版本凍起來，等要安裝時再跑 pip install -r requirements.txt 把原本的套件裝回來。</p><p class="paragraph" style="text-align:left;"># GoodFROM ubuntu:20.04</p><p class="paragraph" style="text-align:left;">RUN apt-get updateRUN apt-get install nginx=1.14.0 python=2.7.15 nodejs=12.18.2</p><p class="paragraph" style="text-align:left;">雖然把套件版本的鎖定之後可以省下很多麻煩，但也不能一直鎖在那都不更新，所以記得偶爾去檢查一下版本是不是太舊了，如果太舊再手動把版號升上去就好了～</p><h1 class="heading" style="text-align:left;">只 COPY 需要的東西</h1><p class="paragraph" style="text-align:left;">平常在寫 Dockerfile 時，有些人為了一時方便，會直接用 COPY . /app 把整個專案資料夾複製到 container 的 /app 資料夾內。這樣不用動太多腦筋，在 container 裡面也可以直接存取到所有檔案，但這樣的做法可以說是糟透了。</p><p class="paragraph" style="text-align:left;">FROM node:14WORKDIR /app</p><p class="paragraph" style="text-align:left;"># Very BADCOPY . .</p><p class="paragraph" style="text-align:left;">RUN npm installRUN npm run testCMD [“node”, “index.js”]</p><p class="paragraph" style="text-align:left;">首先是這樣會讓 image 變得很肥（連 node_modules 都進去了能不肥嗎XD），而且一不小心就會把 .envrc 這類敏感資料一起放進去，如果哪天這個 image 被駭客拿到，裡面的 AWS 憑證、資料庫密碼等等超機密資料就會直接外洩出去，哪天突然被刪庫也是有可能的</p><p class="paragraph" style="text-align:left;">為了避免這種事情發生，在 build image 時應該只把需要的東西複製進去，譬如說你馬上就要跑 npm install，這才把 package.json 跟 package-lock.json 放進去，而程式碼也是把真的會跑到的那些放進去就好。</p><p class="paragraph" style="text-align:left;">FROM node:14WORKDIR /app</p><p class="paragraph" style="text-align:left;"># GoodCOPY package.json package-lock.json ./RUN npm install</p><p class="paragraph" style="text-align:left;"># GoodCOPY src/ index.js ./RUN npm run testCMD [“node”, “index.js”]</p><p class="paragraph" style="text-align:left;">而且這樣還有另外一個好處，就是如果你改了 src 裡面的程式碼，但沒有安裝新的 package（開發時大部分都是這樣吧～），因為 Docker 會自動做 cache，所以就不需要重新跑一次 npm install，會直接從第 10 行的 npm run test 開始跑，因此可以大幅縮減需要等待的時間</p><h1 class="heading" style="text-align:left;">用 multi-stage build 捨棄不需要的檔案</h1><p class="paragraph" style="text-align:left;">這跟上一點有點類似，簡單來說就是不要留任何不需要的東西在 image 裡面（沒用的東西都給我滾），即便那是 build image 過程中產生的東西也是一樣</p><p class="paragraph" style="text-align:left;">譬如說原本 Go API server 的 Dockerfile 可能長這樣，因為要在 build image 時編譯出執行檔，所以第 5 行的 COPY *.go 是一定要的，沒有他們就無法進行編譯。</p><p class="paragraph" style="text-align:left;">FROM golang:1.17</p><p class="paragraph" style="text-align:left;">WORKDIR /app</p><p class="paragraph" style="text-align:left;">COPY *.go go.mod go.sum ./RUN go build -o main</p><p class="paragraph" style="text-align:left;">CMD [“./main”]</p><p class="paragraph" style="text-align:left;">但說真的一旦編譯出執行檔之後，那些 Go 程式碼就用不到了，所以應該來個爽快的過河拆橋，用 multi-stage build 把編譯完的執行檔保留下來就好，程式碼什麼的就直接拜拜</p><p class="paragraph" style="text-align:left;">像下面這個這個 Dockerfile 經過 multi-stage build 後 image 裡面就只有 /app/main 這個編譯好的執行檔，沒有任何程式碼以及 Go 的編譯器，非常的存粹。</p><p class="paragraph" style="text-align:left;"># compile stageFROM golang:1.17 as compile-envWORKDIR /appCOPY *.go go.mod go.sum ./RUN go build -o main</p><p class="paragraph" style="text-align:left;"># final stageFROM gcr.io/distroless/baseCOPY –from=compile-env /app/main /appCMD [“/app/main”]</p><p class="paragraph" style="text-align:left;">那這樣有什麼好處呢？除了 image 可以變小很多之外，即便 image 被駭客拿到了，程式碼也不會外流出去（有很多攻擊都是拿到程式碼後從裡面找到漏洞），因此只保留執行檔可以提高安全性</p><p class="paragraph" style="text-align:left;">除此之外，因為環境越複雜就越可能有沒發現的漏洞，而把 base image 從原本的 golang:1.17 換成 Google 提供的 <a class="link" href="https://github.com/GoogleContainerTools/distroless?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile" target="_blank" rel="noopener noreferrer nofollow">distroless image</a> 剛好可以大幅減少環境的複雜度（distroless 幾乎沒裝什麼東西，連 shell 都沒有），也就可以提高安全性</p><h1 class="heading" style="text-align:left;">不要把敏感資料 hardcode 在 Dockerfile 裡面</h1><p class="paragraph" style="text-align:left;">我想這已經是常識等級的安全知識了，因為直接把敏感資料用 ENV 寫在 Dockerfile 裡會讓駭客輕易拿到（只要拿到 image 就可以了），所以絕對不要想不開把資料庫或任何的帳號密碼寫在裡面，ENV 頂多用來設定時區或是 NODE_ENV 這種被看光也不會出事的變數就好，不然哪天資料被偷走真的會哭出來。</p><p class="paragraph" style="text-align:left;">FROM node:14</p><p class="paragraph" style="text-align:left;">ENV TZ=Asia/TaipeiENV NODE_ENV=production</p><p class="paragraph" style="text-align:left;"># Very BadENV PG_HOST=test.postgresql.comENV PG_USER=thisIsmyUserNameENV PG_PASS=mySecretPa55w0rdENV PG_DBNAME=projectName</p><p class="paragraph" style="text-align:left;">COPY . .RUN npm installCMD [“node”, “index.js”]</p><p class="paragraph" style="text-align:left;">如果說 ENV 不能放敏感資料，那這些資料究竟要怎麼被加進環境變數呢？</p><p class="paragraph" style="text-align:left;">答案就是在 docker run 時加上 –env 或是 –env-file <a class="link" href="https://docs.docker.com/engine/reference/commandline/run/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#set-environment-variables--e---env---env-file" target="_blank" rel="noopener noreferrer nofollow">把環境變數塞進去</a>；如果是用 docker-compose 的話，則是<a class="link" href="https://docs.docker.com/compose/environment-variables/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#set-environment-variables-in-containers" target="_blank" rel="noopener noreferrer nofollow">把那些資料寫進 </a>docker-compose.yml<a class="link" href="https://docs.docker.com/compose/environment-variables/?utm_source=beehiiv&utm_medium=William&utm_campaign=dockerfile#set-environment-variables-in-containers" target="_blank" rel="noopener noreferrer nofollow"> 的 environment 裡面</a>，這樣 container 啟動時就會讀到這些變數，而且即便 image 被偷走也不用擔心資料外洩</p><h1 class="heading" style="text-align:left;">弱點掃描</h1><p class="paragraph" style="text-align:left;">可以做的事情都做了之後，最後就是要來用工具來做弱點掃描了。因為做弱描的工具還滿多的，這邊就介紹已經被 Docker 加進 CLI 的 Snyk，他可以把你的環境、安裝的套件丟到他們資料庫去做搜尋，看有哪些潛在的危險</p><p class="paragraph" style="text-align:left;">譬如說我手邊有幾個多年前用 Node.js 寫的 express server，Dockerfile 長這樣（看到 9.2.0 就知道真的是多年前XD，現在都已經 Node 16 了）。</p><p class="paragraph" style="text-align:left;">FROM node:9.2.0</p><p class="paragraph" style="text-align:left;">COPY index.js package.json /app/WORKDIR /appRUN npm install && npm cache clean –force</p><p class="paragraph" style="text-align:left;">CMD node index.js</p><p class="paragraph" style="text-align:left;">先用 docker build . -t app 把 image 建出來後，接著就下 docker scan app 對他做掃描。因為我用的是古早古早以前的 node:9.2.0，所以光 Base Image 的部分掃出來就有 1039 個漏洞，而且其中 99 是屬於 critical 等級的，嚇都嚇死</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9966a832-dc93-4adf-a5c3-0f694396e85f/1_FnBbkmBYd8QA6dt0M-tJIA.png?t=1714610064"/></div><p class="paragraph" style="text-align:left;">除了告訴你有多少漏洞之外，他還會把每個漏洞給列出來（有興趣可以去讀一下那些漏洞的報告，其實都不長），並且告訴你那些漏洞分別在哪些版本修掉了</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/49d6b0cd-a511-4120-87eb-12f873c6c2d1/1_4I7j2coYVQwWZY6wqUSeFQ.png?t=1714610064"/></div><p class="paragraph" style="text-align:left;">如果懶得看那些漏洞的話，也可以直接滑到最底下看他給你的建議，譬如這邊他就建議把 base image 升級到 node:16.7.0，若是不一定要 full image 的話，那 node:16-bullseye-slim 也是不錯的選項，因為安裝的東西更少，所以漏洞自然也更少。</p><p class="paragraph" style="text-align:left;">Debian bullseye 是今年八月剛發佈的版本，可能比較不穩定</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/48ecbfb5-18f0-408a-90a4-2f575b1977d2/1_f3nHZovlPf1kwy0HP1LiqA.png?t=1714610065"/></div><h1 class="heading" style="text-align:left;">總結</h1><p class="paragraph" style="text-align:left;">今天介紹了一些在寫 Dockerfile 時的注意事項，雖然很多都是小地方，但畢竟魔鬼藏在細節裡，想要讓你的 Docker image 更安全，那就連這些小細節都不能放過。</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.beehiiv.com/?utm_campaign=26ee24ee-e085-45a7-8f80-918c1b787a06&utm_medium=post_rss&utm_source=william" target="_blank" rel="noopener noreferrer nofollow">Powered by beehiiv</a></p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=bd130688-9a53-473c-a1f8-4c71a2552da9&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>Docker 實戰系列 (3)</title>
  <description>使用 Volume 保存容器內的數據</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/7ee0007b-6f70-4451-b55b-20e4506665bf/Docker_Cover.png" length="101441" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/docker-collection-3</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/docker-collection-3</guid>
  <pubDate>Fri, 05 Apr 2024 07:24:59 +0000</pubDate>
  <atom:published>2024-04-05T07:24:59Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Ai]]></category>
    <category><![CDATA[Program Coding]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:start;" id="docker-3-volume"><b>Docker 實戰系列（3）：使用 Volume 保存容器內的數據</b></h1><p class="paragraph" style="text-align:left;">沒錯，這時候就需要 volume 了，簡單來說 Volume 就是用來保存容器內的資料的，看看下面這張圖</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*NyEkiVdw2MjS41EZxqjcpg.png"/></div><p class="paragraph" style="text-align:start;">當你使用 volume 時，docker 會在你的本機上隨機新增一個資料夾作為 Local storage area，大部分會在 <code>/var</code> 底下，然後讓這個資料夾跟 container 裡面的某個資料夾互通。</p><p class="paragraph" style="text-align:start;">因為他們是互通的，所以當你 container 裡面的資料夾有任何變更時，本地的資料夾也會跟著變，而且很重要的一點是：<i><b>container 被刪掉時那個資料夾還會原封不動保留在那邊</b></i>，因此<b>我們可以利用這個特性保留容器裡面的資料</b></p><h1 class="heading" style="text-align:start;"><b>實際操作</b></h1><h2 class="heading" style="text-align:start;" id="step-1-volume"><b>Step 1 — 新增一個 volume</b></h2><p class="paragraph" style="text-align:start;">我們新增了一個 volume 叫做 db-data，完成之後可以看到多一個 volume，這時候 docker 已經在本機上新增一個資料夾要給 volume 用</p><div class="codeblock"><pre><code>&gt; docker volume create --name db-data
&gt; docker volume ls</code></pre></div><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*L-LLFPxOg4boJi34ZZu9PA.png"/></div><h2 class="heading" style="text-align:start;" id="step-2-volume"><b>Step 2 — 使用 volume</b></h2><p class="paragraph" style="text-align:start;">在啟動時加一個 <code>-v</code> 參數，就可以指定 volume 要跟容器內哪一個資料夾連通，這邊用的是 <code>/db/data</code>，實際上使用時可以換成資料庫存放資料的路徑</p><p class="paragraph" style="text-align:start;">demo 一下：<br>1. 剛開始先確認 <code>/db/data</code> 裡面什麼檔案都沒有<br>2. 接著在容器內新增一個檔案 <code>file</code><br>3. 最後再確認檔案在不在</p><div class="codeblock"><pre><code>&gt; docker run -v db-data:/db/data -it ubuntu ls -la /db/data
&gt; docker run -v db-data:/db/data -it ubuntu touch /db/data/file
&gt; docker run -v db-data:/db/data -it ubuntu ls -la /db/data</code></pre></div><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*F_bABSWA31tW943APwd35g.png"/></div><p class="paragraph" style="text-align:start;">值得留意的是<i><b>這三個指令是跑在不同的容器裡面</b></i>，所以也就證明了<i><b>當容器被關掉時，資料確實還有保存在 volume 內</b></i>，而且下個容器可以成功讀到上個容器留下的資料</p><h1 class="heading" style="text-align:start;" id="host-volume"><b>Host Volume</b></h1><p class="paragraph" style="text-align:start;">上面那種先 <code>create</code> 再使用的 volume 稱作 <b>named volume</b>，而現在要介紹另外一種叫做 <b>host volume</b>，用來直接<i><b>指定某個資料夾</b></i>跟容器內的資料夾連通</p><p class="paragraph" style="text-align:start;">來一段 demo：<br>1. 檢查 <code>~/app</code> 內沒有 <code>package.json</code><br>2. 指定本機的 <code>~/app</code> 跟容器內的 <code>/app</code> 連通，接著在容器內跑 <code>npm init</code><br>3. 跑完再回本機確認有沒有生出 <code>package.json</code></p><div class="codeblock"><pre><code>&gt; ls -la app
&gt; docker run -v ~/app:/app --workdir /app node:slim npm init -y
&gt; ls -la app</code></pre></div><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*mCjrJjMq8ZEoonx3rpvXUA.png"/></div><p class="paragraph" style="text-align:start;">上面例子中的 <code>package.json</code> 其實是在容器內生成的，所以有了 volume 之後就可以不用裝 yarn 卻還是可以跑 <code>yarn init</code></p><p class="paragraph" style="text-align:start;">同理，你也可以不用裝 <code>g++</code> 就能編譯 C++ 原始碼、不用裝 JDK 就可以開發 Java 程式、甚至不用裝 MongoDB 就可以用他來存資料，整台電腦只要裝一個 docker，真是太神了 🎉🎉</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=2f648df1-250d-4b28-aff2-3883b19233ca&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>Docker 實戰系列 (3)</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2024/04/Docker_Cover-eBwNYm-150x150.png&quot; class=&quot;attachment-thumbnail size</description>
  <link>https://affiliatewilliam.beehiiv.com/p/docker-e5-af-a6-e6-88-b0-e7-b3-bb-e5-88-97-ef-bc-883-ef-bc-89</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/docker-e5-af-a6-e6-88-b0-e7-b3-bb-e5-88-97-ef-bc-883-ef-bc-89</guid>
  <pubDate>Fri, 05 Apr 2024 07:24:59 +0000</pubDate>
  <atom:published>2024-04-05T07:24:59Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/c5a2a5e2-dcb8-4a9c-8b9d-81364af0ff32/Docker_Cover-eBwNYm-150x150.png?t=1714610066"/></div><h1 class="heading" style="text-align:left;">Docker 實戰系列（3）：使用 Volume 保存容器內的數據</h1><p class="paragraph" style="text-align:left;">沒錯，這時候就需要 volume 了，簡單來說 Volume 就是用來保存容器內的資料的，看看下面這張圖</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/5bf5f8ed-2324-4ae5-ba2f-35c5f0fc2b38/1_NyEkiVdw2MjS41EZxqjcpg.png?t=1714610067"/></div><p class="paragraph" style="text-align:left;">當你使用 volume 時，docker 會在你的本機上隨機新增一個資料夾作為 Local storage area，大部分會在 /var 底下，然後讓這個資料夾跟 container 裡面的某個資料夾互通。</p><p class="paragraph" style="text-align:left;">因為他們是互通的，所以當你 container 裡面的資料夾有任何變更時，本地的資料夾也會跟著變，而且很重要的一點是：container 被刪掉時那個資料夾還會原封不動保留在那邊，因此我們可以利用這個特性保留容器裡面的資料</p><h1 class="heading" style="text-align:left;">實際操作</h1><h2 class="heading" style="text-align:left;">Step 1 — 新增一個 volume</h2><p class="paragraph" style="text-align:left;">我們新增了一個 volume 叫做 db-data，完成之後可以看到多一個 volume，這時候 docker 已經在本機上新增一個資料夾要給 volume 用</p><p class="paragraph" style="text-align:left;">&gt; docker volume create –name db-data&gt; docker volume ls</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ed57bdbc-f230-4b8b-b19d-f4a9e313fa3c/1_L-LLFPxOg4boJi34ZZu9PA.png?t=1714610067"/></div><h2 class="heading" style="text-align:left;">Step 2 — 使用 volume</h2><p class="paragraph" style="text-align:left;">在啟動時加一個 -v 參數，就可以指定 volume 要跟容器內哪一個資料夾連通，這邊用的是 /db/data，實際上使用時可以換成資料庫存放資料的路徑</p><p class="paragraph" style="text-align:left;">demo 一下：1. 剛開始先確認 /db/data 裡面什麼檔案都沒有2. 接著在容器內新增一個檔案 file3. 最後再確認檔案在不在</p><p class="paragraph" style="text-align:left;">&gt; docker run -v db-data:/db/data -it ubuntu ls -la /db/data&gt; docker run -v db-data:/db/data -it ubuntu touch /db/data/file&gt; docker run -v db-data:/db/data -it ubuntu ls -la /db/data</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/80b173a7-5acc-4c97-b99a-85e57f372735/1_F_bABSWA31tW943APwd35g.png?t=1714610067"/></div><p class="paragraph" style="text-align:left;">值得留意的是這三個指令是跑在不同的容器裡面，所以也就證明了當容器被關掉時，資料確實還有保存在 volume 內，而且下個容器可以成功讀到上個容器留下的資料</p><h1 class="heading" style="text-align:left;">Host Volume</h1><p class="paragraph" style="text-align:left;">上面那種先 create 再使用的 volume 稱作 named volume，而現在要介紹另外一種叫做 host volume，用來直接指定某個資料夾跟容器內的資料夾連通</p><p class="paragraph" style="text-align:left;">來一段 demo：1. 檢查 ~/app 內沒有 package.json2. 指定本機的 ~/app 跟容器內的 /app 連通，接著在容器內跑 npm init3. 跑完再回本機確認有沒有生出 package.json</p><p class="paragraph" style="text-align:left;">&gt; ls -la app&gt; docker run -v ~/app:/app –workdir /app node:slim npm init -y&gt; ls -la app</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/6e96bfe6-41ed-4929-89f1-cc918d77e04a/1_mCjrJjMq8ZEoonx3rpvXUA.png?t=1714610067"/></div><p class="paragraph" style="text-align:left;">上面例子中的 package.json 其實是在容器內生成的，所以有了 volume 之後就可以不用裝 yarn 卻還是可以跑 yarn init</p><p class="paragraph" style="text-align:left;">同理，你也可以不用裝 g++ 就能編譯 C++ 原始碼、不用裝 JDK 就可以開發 Java 程式、甚至不用裝 MongoDB 就可以用他來存資料，整台電腦只要裝一個 docker，真是太神了 </p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.beehiiv.com/?utm_campaign=2f648df1-250d-4b28-aff2-3883b19233ca&utm_medium=post_rss&utm_source=william" target="_blank" rel="noopener noreferrer nofollow">Powered by beehiiv</a></p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=b2495dae-40b3-4b53-ab70-aae83db2ec0c&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>Docker 實戰系列(2)</title>
  <description>Docker Hub 上分享自己的 imageDocker 實戰系列(2)</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/7ee0007b-6f70-4451-b55b-20e4506665bf/Docker_Cover.png" length="101441" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/docker-collection-application-2</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/docker-collection-application-2</guid>
  <pubDate>Fri, 05 Apr 2024 05:36:38 +0000</pubDate>
  <atom:published>2024-04-05T05:36:38Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Ai]]></category>
    <category><![CDATA[Program Coding]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:start;" id="docker-2"><b>Docker 實戰系列（2）：</b></h1><h1 class="heading" style="text-align:start;" id="docker-hub-image-docker-2-docker-hu"><b>Docker Hub 上分享自己的 imageDocker 實戰系列（2）：在於 Docker Hub 上分享自己的 image</b></h1><p class="paragraph" style="text-align:left;">看完上一篇<span style="text-decoration:underline;"><a class="link" href="https://affiliatewilliam.beehiiv.com/p/docker-collection-application-1?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">一步一步帶你 dockerize 你的應用</a></span>之後，我已經會寫 Dockerfile 也知道怎麼 build 出自己的 image 了，但是我要怎麼把 image 分享出去給別人使用呢？<b>沒錯，這就是這篇要講的</b></p><h1 class="heading" style="text-align:left;" id="docker-registry"><b>Docker Registry</b></h1><p class="paragraph" style="text-align:left;"><span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/explore/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a></span> 是官方提供的 Docker Registry，所謂的 Docker Registry 就是一個讓大家可以 pull（下載）或是 push（上傳）image 的地方，把 image 上傳到 Docker Registry 後大家就可以直接 pull 下來用，不用再根據 Dockerfile 自建出 image</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*HVMiMMC_Ds1uVBkUMDiUZA.png"/></div><h1 class="heading" style="text-align:left;" id="vs-image"><b>官方 VS 非官方 image</b></h1><p class="paragraph" style="text-align:left;">在 Docker Hub 上的 image 有分成官方跟非官方兩種，像 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/ubuntu/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">ubuntu</a></span>、<span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/mysql/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">mysql</a></span> 這種就是官方的，在安全性跟品質上也比較有保證，要使用就直接 <code>docker pull &lt;image&gt;</code> 就可以了</p><p class="paragraph" style="text-align:left;">那像 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/r/larry850806/nodejs-workspace/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">larry850806/nodejs-workspace</a></span> 這個是我自己 build 出來的 image，前面就會有我的 username，如果要 pull 下來的話就要 <code>docker pull larry850806/nodejs-workspace</code></p><h1 class="heading" style="text-align:left;" id="build-and-push-to-docker-hub"><b>Build And Push To Docker Hub</b></h1><p class="paragraph" style="text-align:left;">這次要教大家在 Docker Hub 上分享自己的 image，如果還沒有 Docker Hub 帳號的可以先去申請一個，這次也會用 <span style="text-decoration:underline;"><a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a></span> 當做範例，如果你有其他專案可以 build 出 image 也可以拿來試試看</p><h2 class="heading" style="text-align:left;" id="build-from-dockerfile"><b>Build From Dockerfile</b></h2><p class="paragraph" style="text-align:left;">因為要上傳到 Docker Hub 上面，所以在 build 時要加上自己的 username，像我就是 <code>docker build -t larry850806/simple-express-server .</code>，build 完會多一個叫做 <code>larry850806/simple-express-server</code> 的 image，這個 image 總共是 677 MB（么壽好肥）</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*qGKvosfiFdalqrmwoTRUWQ.png"/></div><h2 class="heading" style="text-align:left;" id="login"><b>Login</b></h2><p class="paragraph" style="text-align:left;">在 push 之前必須先跑 <code>docker login</code> 登入，如果有申請帳號的話應該是不會有什麼問題，打打帳號密碼就 ok 了，另外如果你之前已經登入過就不用再次登入囉～ docker 會幫你把 credential 存起來</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*FYD0icIdIKQ14bLwerlMkQ.png"/></div><h2 class="heading" style="text-align:left;" id="push-to-docker-hub"><b>Push To Docker Hub</b></h2><p class="paragraph" style="text-align:left;">登入完就直接跑 <code>docker push larry850806/simple-express-server</code> 把 image push 上去，但你可能會想，這個 image 有 <i><b>677MB</b></i> 欸，這樣不就要 push 超久嗎？就像是要傳一個超～大的檔案上去 server 一樣</p><p class="paragraph" style="text-align:left;">其實不會，還記得之前說過 image 是一層一層疊加起來的嗎，現在這個 image 是 based on <code>node:9.2.0</code>，你在 push 的時候他只會上傳你新增的幾層，至於<b>底下沒變更的那幾層就不需要 push</b>，直接沿用 <code>node:9.2.0</code> 的</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*WIV53-bx4iRPHhi6cqOHrA.png"/></div><p class="paragraph" style="text-align:left;">可以看到很多層都是 <code>Mounted from library/node</code>，真正需要 push 的只有最上面的兩層，所以還滿快的，push 完到 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a></span> 上面就可以看到自己發佈的 image 了～因為是公開的所以別人也可以使用</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*EDzNpBJ8pCGlicJw1rRQrw.png"/></div><div class="blockquote"><blockquote class="blockquote__quote"><p class="paragraph" style="text-align:left;"><i>但每次更新了 source code 或是 Dockerfile 之後，都要自己 build 再 push 上去，這樣很麻煩欸，有沒有工具可以自動幫我做這些事阿？</i></p><figcaption class="blockquote__byline"></figcaption></blockquote></div><h1 class="heading" style="text-align:left;" id="automated-build"><b>Automated Build</b></h1><p class="paragraph" style="text-align:left;">Automated Build 是 Docker Hub 提供的功能，他可以在你的 Github repo 有更新時就馬上根據 Dockerfile 幫你 build 一個新的 image，要使用這個功能首先到 Docker Hub 右上角點選 <i><b>Create Automated Build</b></i></p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:496/1*a5fqJARt4NHR5iQ194n0HA.png"/></div><p class="paragraph" style="text-align:left;">接著選 Github 或是 Bitbucket 告訴他你想幫哪個 repo 建立 Automated Build，我這邊是選我自己的 <span style="text-decoration:underline;"><a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a></span>，因為 build 需要 Dockerfile，如果你現在手上沒有任何專案有 Dockerfile 的話，可以 fork 我的專案跟著做做看</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:601/1*maboNuprETzshpSa5y_hgw.png"/></div><p class="paragraph" style="text-align:left;">給他一個 image 名字跟簡短的說明就可以了</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*GCN4sHYrtQ16gUX0oDVsHQ.png"/></div><h2 class="heading" style="text-align:left;"><b>設定觸發時機</b></h2><p class="paragraph" style="text-align:left;">新增完到 Build Settings 裡面看一下，現在有兩條規則：</p><ol start="1"><li><p class="paragraph" style="text-align:left;">每次 master 有新的 commit 時就自動 build 一個 <code>image:latest</code></p></li><li><p class="paragraph" style="text-align:left;">每次某個 branch 有新的 commit 時自動 build 一個 <code>image:&lt;branch name&gt;</code></p></li></ol><p class="paragraph" style="text-align:left;">基本上不需要去改他，除非你要做更進階的設定</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*kcovv9Q15OZboEOf-MRR-g.png"/></div><h2 class="heading" style="text-align:left;" id="push-github"><b>Push 新版本到 Github 上</b></h2><p class="paragraph" style="text-align:left;">Automated Build 已經設定完了，實際 push 一個新的 commit 到 Github 上，會看到 Build Details 裡面多了一個正在 build 的 image，之前說過只要有一樣的 Dockerfile，不管在哪裡 build 結果都會是一樣的，現在就是在 Docker 官方的主機上 Build</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*3USzuGMyapba8qRhZbk1Jw.png"/></div><h2 class="heading" style="text-align:left;"><b>設定通知</b></h2><p class="paragraph" style="text-align:left;">如果在 build 的過程中發生了錯誤，那你應該會想收到通知吧？可以到<span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/settings/notifications?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">通知</a></span>這邊設定一下，發生錯誤的時候就會寄信跟你說</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*rx2euCE6V_w27iGlDiKBuA.png"/></div><p class="paragraph" style="text-align:left;">整個都設定完了之後就輕鬆了～以後只要有任何新的 code push 到 Github repo 上，Docker Hub 就會馬上 build 出一個新的 image，如果要在 server 上部屬的話直接從 Docker Hub 把它 pull 下來跑就可以了</p><h1 class="heading" style="text-align:left;"><b>題外話</b></h1><p class="paragraph" style="text-align:left;">雖然 Docker Hub 上的 Automated Build 看起來很猛很方便 XD，但也是有缺點的，在 Docker Hub 上最多只能有一個私人專案，超過就不能再建立了</p><p class="paragraph" style="text-align:left;">但也不可能因此把私人或公司專案設公開，因為裡面有你的 code 還有 API_KEY 等等敏感資料，所以只能乖乖花錢買私人專案的額度，或是用其他免費的 docker registery 像是 <span style="text-decoration:underline;"><a class="link" href="https://canister.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">canister</a></span> 或是 <span style="text-decoration:underline;"><a class="link" href="https://treescale.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">treescale</a></span>，如果考量安全性的話也可以自己架，但就會稍微麻煩一點<span style="color:rgb(36, 36, 36);font-family:source-serif-pro, Georgia, Cambria, Times New Roman, Times, serif;font-size:20px;">看完上一篇</span><span style="text-decoration:underline;"><a class="link" href="https://larrylu.blog/step-by-step-dockerize-your-app-ecd8940696f4?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">一步一步帶你 dockerize 你的應用</a></span><span style="color:rgb(36, 36, 36);font-family:source-serif-pro, Georgia, Cambria, Times New Roman, Times, serif;font-size:20px;">之後，我已經會寫 Dockerfile 也知道怎麼 build 出自己的 image 了，但是我要怎麼把 image 分享出去給別人使用呢？</span><span style="color:rgb(36, 36, 36);font-family:source-serif-pro, Georgia, Cambria, Times New Roman, Times, serif;font-size:20px;"><b>沒錯，這就是這篇要講的</b></span></p><h1 class="heading" style="text-align:left;" id="docker-registry">Docker Registry</h1><p class="paragraph" style="text-align:left;"><span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/explore/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a></span> 是官方提供的 Docker Registry，所謂的 Docker Registry 就是一個讓大家可以 pull（下載）或是 push（上傳）image 的地方，把 image 上傳到 Docker Registry 後大家就可以直接 pull 下來用，不用再根據 Dockerfile 自建出 image</p><h1 class="heading" style="text-align:left;" id="vs-image">官方 VS 非官方 image</h1><p class="paragraph" style="text-align:left;">在 Docker Hub 上的 image 有分成官方跟非官方兩種，像 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/ubuntu/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">ubuntu</a></span>、<span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/mysql/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">mysql</a></span> 這種就是官方的，在安全性跟品質上也比較有保證，要使用就直接 <code>docker pull &lt;image&gt;</code> 就可以了</p><p class="paragraph" style="text-align:left;">那像 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/r/larry850806/nodejs-workspace/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">larry850806/nodejs-workspace</a></span> 這個是我自己 build 出來的 image，前面就會有我的 username，如果要 pull 下來的話就要 <code>docker pull larry850806/nodejs-workspace</code></p><h1 class="heading" style="text-align:left;" id="build-and-push-to-docker-hub">Build And Push To Docker Hub</h1><p class="paragraph" style="text-align:left;">這次要教大家在 Docker Hub 上分享自己的 image，如果還沒有 Docker Hub 帳號的可以先去申請一個，這次也會用 <span style="text-decoration:underline;"><a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a></span> 當做範例，如果你有其他專案可以 build 出 image 也可以拿來試試看</p><h2 class="heading" style="text-align:left;" id="build-from-dockerfile">Build From Dockerfile</h2><p class="paragraph" style="text-align:left;">因為要上傳到 Docker Hub 上面，所以在 build 時要加上自己的 username，像我就是 <code>docker build -t larry850806/simple-express-server .</code>，build 完會多一個叫做 <code>larry850806/simple-express-server</code> 的 image，這個 image 總共是 677 MB（么壽好肥）</p><h2 class="heading" style="text-align:left;" id="login">Login</h2><p class="paragraph" style="text-align:left;">在 push 之前必須先跑 <code>docker login</code> 登入，如果有申請帳號的話應該是不會有什麼問題，打打帳號密碼就 ok 了，另外如果你之前已經登入過就不用再次登入囉～ docker 會幫你把 credential 存起來</p><h2 class="heading" style="text-align:left;" id="push-to-docker-hub">Push To Docker Hub</h2><p class="paragraph" style="text-align:left;">登入完就直接跑 <code>docker push larry850806/simple-express-server</code> 把 image push 上去，但你可能會想，這個 image 有 <i><b>677MB</b></i> 欸，這樣不就要 push 超久嗎？就像是要傳一個超～大的檔案上去 server 一樣</p><p class="paragraph" style="text-align:left;">其實不會，還記得之前說過 image 是一層一層疊加起來的嗎，現在這個 image 是 based on <code>node:9.2.0</code>，你在 push 的時候他只會上傳你新增的幾層，至於<b>底下沒變更的那幾層就不需要 push</b>，直接沿用 <code>node:9.2.0</code> 的</p><p class="paragraph" style="text-align:left;">可以看到很多層都是 <code>Mounted from library/node</code>，真正需要 push 的只有最上面的兩層，所以還滿快的，push 完到 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a></span> 上面就可以看到自己發佈的 image 了～因為是公開的所以別人也可以使用</p><div class="blockquote"><blockquote class="blockquote__quote"><p class="paragraph" style="text-align:left;"><i>但每次更新了 source code 或是 Dockerfile 之後，都要自己 build 再 push 上去，這樣很麻煩欸，有沒有工具可以自動幫我做這些事阿？</i></p><figcaption class="blockquote__byline"></figcaption></blockquote></div><h1 class="heading" style="text-align:left;" id="automated-build">Automated Build</h1><p class="paragraph" style="text-align:left;">Automated Build 是 Docker Hub 提供的功能，他可以在你的 Github repo 有更新時就馬上根據 Dockerfile 幫你 build 一個新的 image，要使用這個功能首先到 Docker Hub 右上角點選 <i><b>Create Automated Build</b></i></p><p class="paragraph" style="text-align:left;">接著選 Github 或是 Bitbucket 告訴他你想幫哪個 repo 建立 Automated Build，我這邊是選我自己的 <span style="text-decoration:underline;"><a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a></span>，因為 build 需要 Dockerfile，如果你現在手上沒有任何專案有 Dockerfile 的話，可以 fork 我的專案跟著做做看</p><p class="paragraph" style="text-align:left;">給他一個 image 名字跟簡短的說明就可以了</p><h2 class="heading" style="text-align:left;">設定觸發時機</h2><p class="paragraph" style="text-align:left;">新增完到 Build Settings 裡面看一下，現在有兩條規則：</p><ol start="1"><li><p class="paragraph" style="text-align:left;">每次 master 有新的 commit 時就自動 build 一個 <code>image:latest</code></p></li><li><p class="paragraph" style="text-align:left;">每次某個 branch 有新的 commit 時自動 build 一個 <code>image:&lt;branch name&gt;</code></p></li></ol><p class="paragraph" style="text-align:left;">基本上不需要去改他，除非你要做更進階的設定</p><h2 class="heading" style="text-align:left;" id="push-github">Push 新版本到 Github 上</h2><p class="paragraph" style="text-align:left;">Automated Build 已經設定完了，實際 push 一個新的 commit 到 Github 上，會看到 Build Details 裡面多了一個正在 build 的 image，之前說過只要有一樣的 Dockerfile，不管在哪裡 build 結果都會是一樣的，現在就是在 Docker 官方的主機上 Build</p><h2 class="heading" style="text-align:left;">設定通知</h2><p class="paragraph" style="text-align:left;">如果在 build 的過程中發生了錯誤，那你應該會想收到通知吧？可以到<span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/settings/notifications?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">通知</a></span>這邊設定一下，發生錯誤的時候就會寄信跟你說</p><p class="paragraph" style="text-align:left;">整個都設定完了之後就輕鬆了～以後只要有任何新的 code push 到 Github repo 上，Docker Hub 就會馬上 build 出一個新的 image，如果要在 server 上部屬的話直接從 Docker Hub 把它 pull 下來跑就可以了</p><h1 class="heading" style="text-align:left;">題外話</h1><p class="paragraph" style="text-align:left;">雖然 Docker Hub 上的 Automated Build 看起來很猛很方便 XD，但也是有缺點的，在 Docker Hub 上最多只能有一個私人專案，超過就不能再建立了</p><p class="paragraph" style="text-align:left;">但也不可能因此把私人或公司專案設公開，因為裡面有你的 code 還有 API_KEY 等等敏感資料，所以只能乖乖花錢買私人專案的額度，或是用其他免費的 docker registery 像是 <span style="text-decoration:underline;"><a class="link" href="https://canister.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">canister</a></span> 或是 <span style="text-decoration:underline;"><a class="link" href="https://treescale.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">treescale</a></span>，如果考量安全性的話也可以自己架，但就會稍微麻煩一點</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=87b7ed2c-0b24-4535-88a5-b3572d091ba5&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>Docker 實戰系列(2)</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2024/04/Docker_Cover-4KYYXA-150x150.png&quot; class=&quot;attachment-thumbnail size</description>
  <link>https://affiliatewilliam.beehiiv.com/p/docker-e5-af-a6-e6-88-b0-e7-b3-bb-e5-88-97-ef-bc-882-ef-bc-89</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/docker-e5-af-a6-e6-88-b0-e7-b3-bb-e5-88-97-ef-bc-882-ef-bc-89</guid>
  <pubDate>Fri, 05 Apr 2024 05:36:38 +0000</pubDate>
  <atom:published>2024-04-05T05:36:38Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/80583dfd-37fa-4e16-acf0-99941a250657/Docker_Cover-4KYYXA-150x150.png?t=1714610070"/></div><h1 class="heading" style="text-align:left;">Docker 實戰系列（2）：</h1><h1 class="heading" style="text-align:left;">Docker Hub 上分享自己的 imageDocker 實戰系列（2）：在於 Docker Hub 上分享自己的 image</h1><p class="paragraph" style="text-align:left;">看完上一篇<a class="link" href="https://affiliatewilliam.beehiiv.com/p/docker-collection-application-1?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">一步一步帶你 dockerize 你的應用</a>之後，我已經會寫 Dockerfile 也知道怎麼 build 出自己的 image 了，但是我要怎麼把 image 分享出去給別人使用呢？沒錯，這就是這篇要講的</p><h1 class="heading" style="text-align:left;">Docker Registry</h1><p class="paragraph" style="text-align:left;"><a class="link" href="https://hub.docker.com/explore/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a> 是官方提供的 Docker Registry，所謂的 Docker Registry 就是一個讓大家可以 pull（下載）或是 push（上傳）image 的地方，把 image 上傳到 Docker Registry 後大家就可以直接 pull 下來用，不用再根據 Dockerfile 自建出 image</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/b32f3644-155e-4bc9-abd0-7e8829839f60/1_HVMiMMC_Ds1uVBkUMDiUZA.png?t=1714610070"/></div><h1 class="heading" style="text-align:left;">官方 VS 非官方 image</h1><p class="paragraph" style="text-align:left;">在 Docker Hub 上的 image 有分成官方跟非官方兩種，像 <a class="link" href="https://hub.docker.com/_/ubuntu/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">ubuntu</a>、<a class="link" href="https://hub.docker.com/_/mysql/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">mysql</a> 這種就是官方的，在安全性跟品質上也比較有保證，要使用就直接 docker pull &lt;image&gt; 就可以了</p><p class="paragraph" style="text-align:left;">那像 <a class="link" href="https://hub.docker.com/r/larry850806/nodejs-workspace/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">larry850806/nodejs-workspace</a> 這個是我自己 build 出來的 image，前面就會有我的 username，如果要 pull 下來的話就要 docker pull larry850806/nodejs-workspace</p><h1 class="heading" style="text-align:left;">Build And Push To Docker Hub</h1><p class="paragraph" style="text-align:left;">這次要教大家在 Docker Hub 上分享自己的 image，如果還沒有 Docker Hub 帳號的可以先去申請一個，這次也會用 <a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a> 當做範例，如果你有其他專案可以 build 出 image 也可以拿來試試看</p><h2 class="heading" style="text-align:left;">Build From Dockerfile</h2><p class="paragraph" style="text-align:left;">因為要上傳到 Docker Hub 上面，所以在 build 時要加上自己的 username，像我就是 docker build -t larry850806/simple-express-server .，build 完會多一個叫做 larry850806/simple-express-server 的 image，這個 image 總共是 677 MB（么壽好肥）</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/bc3e2860-7db6-42ba-8c52-d31e670b0986/1_qGKvosfiFdalqrmwoTRUWQ.png?t=1714610071"/></div><h2 class="heading" style="text-align:left;">Login</h2><p class="paragraph" style="text-align:left;">在 push 之前必須先跑 docker login 登入，如果有申請帳號的話應該是不會有什麼問題，打打帳號密碼就 ok 了，另外如果你之前已經登入過就不用再次登入囉～ docker 會幫你把 credential 存起來</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/0b10b020-cefc-43b0-ba22-f06a5a0190b5/1_FYD0icIdIKQ14bLwerlMkQ.png?t=1714610071"/></div><h2 class="heading" style="text-align:left;">Push To Docker Hub</h2><p class="paragraph" style="text-align:left;">登入完就直接跑 docker push larry850806/simple-express-server 把 image push 上去，但你可能會想，這個 image 有 677MB 欸，這樣不就要 push 超久嗎？就像是要傳一個超～大的檔案上去 server 一樣</p><p class="paragraph" style="text-align:left;">其實不會，還記得之前說過 image 是一層一層疊加起來的嗎，現在這個 image 是 based on node:9.2.0，你在 push 的時候他只會上傳你新增的幾層，至於底下沒變更的那幾層就不需要 push，直接沿用 node:9.2.0 的</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/3f3a430d-6ade-4fe9-adc8-8891dffa537a/1_WIV53-bx4iRPHhi6cqOHrA.png?t=1714610072"/></div><p class="paragraph" style="text-align:left;">可以看到很多層都是 Mounted from library/node，真正需要 push 的只有最上面的兩層，所以還滿快的，push 完到 <a class="link" href="https://hub.docker.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a> 上面就可以看到自己發佈的 image 了～因為是公開的所以別人也可以使用</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/bef89f07-7063-4bdb-b3d8-94fdb097394c/1_EDzNpBJ8pCGlicJw1rRQrw.png?t=1714610072"/></div><p class="paragraph" style="text-align:left;">但每次更新了 source code 或是 Dockerfile 之後，都要自己 build 再 push 上去，這樣很麻煩欸，有沒有工具可以自動幫我做這些事阿？</p><h1 class="heading" style="text-align:left;">Automated Build</h1><p class="paragraph" style="text-align:left;">Automated Build 是 Docker Hub 提供的功能，他可以在你的 Github repo 有更新時就馬上根據 Dockerfile 幫你 build 一個新的 image，要使用這個功能首先到 Docker Hub 右上角點選 Create Automated Build</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/013467bb-f389-4dc0-a020-a65d48b81269/1_a5fqJARt4NHR5iQ194n0HA.png?t=1714610073"/></div><p class="paragraph" style="text-align:left;">接著選 Github 或是 Bitbucket 告訴他你想幫哪個 repo 建立 Automated Build，我這邊是選我自己的 <a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a>，因為 build 需要 Dockerfile，如果你現在手上沒有任何專案有 Dockerfile 的話，可以 fork 我的專案跟著做做看</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/28ae3d49-ee7a-404e-b63f-7cbc4659f1b1/1_maboNuprETzshpSa5y_hgw.png?t=1714610073"/></div><p class="paragraph" style="text-align:left;">給他一個 image 名字跟簡短的說明就可以了</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/e2cac659-ce1c-437f-bc4f-e52c0362f492/1_GCN4sHYrtQ16gUX0oDVsHQ.png?t=1714610073"/></div><h2 class="heading" style="text-align:left;">設定觸發時機</h2><p class="paragraph" style="text-align:left;">新增完到 Build Settings 裡面看一下，現在有兩條規則：</p><p class="paragraph" style="text-align:left;">每次 master 有新的 commit 時就自動 build 一個 image:latest</p><p class="paragraph" style="text-align:left;">每次某個 branch 有新的 commit 時自動 build 一個 image:&lt;branch name&gt;</p><p class="paragraph" style="text-align:left;">基本上不需要去改他，除非你要做更進階的設定</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/6b819132-4062-431b-8d16-091ab5d34416/1_kcovv9Q15OZboEOf-MRR-g.png?t=1714610074"/></div><h2 class="heading" style="text-align:left;">Push 新版本到 Github 上</h2><p class="paragraph" style="text-align:left;">Automated Build 已經設定完了，實際 push 一個新的 commit 到 Github 上，會看到 Build Details 裡面多了一個正在 build 的 image，之前說過只要有一樣的 Dockerfile，不管在哪裡 build 結果都會是一樣的，現在就是在 Docker 官方的主機上 Build</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/0e1ba8f6-13bb-4ff7-b5fe-152e77455ebb/1_3USzuGMyapba8qRhZbk1Jw.png?t=1714610074"/></div><h2 class="heading" style="text-align:left;">設定通知</h2><p class="paragraph" style="text-align:left;">如果在 build 的過程中發生了錯誤，那你應該會想收到通知吧？可以到<a class="link" href="https://hub.docker.com/settings/notifications?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">通知</a>這邊設定一下，發生錯誤的時候就會寄信跟你說</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/026a5660-959b-4fdb-b67c-a346fd91f015/1_rx2euCE6V_w27iGlDiKBuA.png?t=1714610075"/></div><p class="paragraph" style="text-align:left;">整個都設定完了之後就輕鬆了～以後只要有任何新的 code push 到 Github repo 上，Docker Hub 就會馬上 build 出一個新的 image，如果要在 server 上部屬的話直接從 Docker Hub 把它 pull 下來跑就可以了</p><h1 class="heading" style="text-align:left;">題外話</h1><p class="paragraph" style="text-align:left;">雖然 Docker Hub 上的 Automated Build 看起來很猛很方便 XD，但也是有缺點的，在 Docker Hub 上最多只能有一個私人專案，超過就不能再建立了</p><p class="paragraph" style="text-align:left;">但也不可能因此把私人或公司專案設公開，因為裡面有你的 code 還有 API_KEY 等等敏感資料，所以只能乖乖花錢買私人專案的額度，或是用其他免費的 docker registery 像是 <a class="link" href="https://canister.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">canister</a> 或是 <a class="link" href="https://treescale.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">treescale</a>，如果考量安全性的話也可以自己架，但就會稍微麻煩一點看完上一篇<a class="link" href="https://larrylu.blog/step-by-step-dockerize-your-app-ecd8940696f4?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">一步一步帶你 dockerize 你的應用</a>之後，我已經會寫 Dockerfile 也知道怎麼 build 出自己的 image 了，但是我要怎麼把 image 分享出去給別人使用呢？沒錯，這就是這篇要講的</p><h1 class="heading" style="text-align:left;">Docker Registry</h1><p class="paragraph" style="text-align:left;"><a class="link" href="https://hub.docker.com/explore/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a> 是官方提供的 Docker Registry，所謂的 Docker Registry 就是一個讓大家可以 pull（下載）或是 push（上傳）image 的地方，把 image 上傳到 Docker Registry 後大家就可以直接 pull 下來用，不用再根據 Dockerfile 自建出 image</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/6204c749-6512-4a0a-ad0f-8fce89c31fbb/1_HVMiMMC_Ds1uVBkUMDiUZA.png?t=1714610075"/></div><h1 class="heading" style="text-align:left;">官方 VS 非官方 image</h1><p class="paragraph" style="text-align:left;">在 Docker Hub 上的 image 有分成官方跟非官方兩種，像 <a class="link" href="https://hub.docker.com/_/ubuntu/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">ubuntu</a>、<a class="link" href="https://hub.docker.com/_/mysql/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">mysql</a> 這種就是官方的，在安全性跟品質上也比較有保證，要使用就直接 docker pull &lt;image&gt; 就可以了</p><p class="paragraph" style="text-align:left;">那像 <a class="link" href="https://hub.docker.com/r/larry850806/nodejs-workspace/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">larry850806/nodejs-workspace</a> 這個是我自己 build 出來的 image，前面就會有我的 username，如果要 pull 下來的話就要 docker pull larry850806/nodejs-workspace</p><h1 class="heading" style="text-align:left;">Build And Push To Docker Hub</h1><p class="paragraph" style="text-align:left;">這次要教大家在 Docker Hub 上分享自己的 image，如果還沒有 Docker Hub 帳號的可以先去申請一個，這次也會用 <a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a> 當做範例，如果你有其他專案可以 build 出 image 也可以拿來試試看</p><h2 class="heading" style="text-align:left;">Build From Dockerfile</h2><p class="paragraph" style="text-align:left;">因為要上傳到 Docker Hub 上面，所以在 build 時要加上自己的 username，像我就是 docker build -t larry850806/simple-express-server .，build 完會多一個叫做 larry850806/simple-express-server 的 image，這個 image 總共是 677 MB（么壽好肥）</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/91e8bbde-ed28-4b26-91df-f2d352274f4c/1_qGKvosfiFdalqrmwoTRUWQ.png?t=1714610075"/></div><h2 class="heading" style="text-align:left;">Login</h2><p class="paragraph" style="text-align:left;">在 push 之前必須先跑 docker login 登入，如果有申請帳號的話應該是不會有什麼問題，打打帳號密碼就 ok 了，另外如果你之前已經登入過就不用再次登入囉～ docker 會幫你把 credential 存起來</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/7c0a2108-543c-4268-b9ef-fd0b142aa340/1_FYD0icIdIKQ14bLwerlMkQ.png?t=1714610075"/></div><h2 class="heading" style="text-align:left;">Push To Docker Hub</h2><p class="paragraph" style="text-align:left;">登入完就直接跑 docker push larry850806/simple-express-server 把 image push 上去，但你可能會想，這個 image 有 677MB 欸，這樣不就要 push 超久嗎？就像是要傳一個超～大的檔案上去 server 一樣</p><p class="paragraph" style="text-align:left;">其實不會，還記得之前說過 image 是一層一層疊加起來的嗎，現在這個 image 是 based on node:9.2.0，你在 push 的時候他只會上傳你新增的幾層，至於底下沒變更的那幾層就不需要 push，直接沿用 node:9.2.0 的</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9f54900a-51d3-4689-adf2-24e1764928c0/1_WIV53-bx4iRPHhi6cqOHrA.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;">可以看到很多層都是 Mounted from library/node，真正需要 push 的只有最上面的兩層，所以還滿快的，push 完到 <a class="link" href="https://hub.docker.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a> 上面就可以看到自己發佈的 image 了～因為是公開的所以別人也可以使用</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/f11c0566-7efb-4f06-83c7-e56e7f839751/1_EDzNpBJ8pCGlicJw1rRQrw.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;">但每次更新了 source code 或是 Dockerfile 之後，都要自己 build 再 push 上去，這樣很麻煩欸，有沒有工具可以自動幫我做這些事阿？</p><h1 class="heading" style="text-align:left;">Automated Build</h1><p class="paragraph" style="text-align:left;">Automated Build 是 Docker Hub 提供的功能，他可以在你的 Github repo 有更新時就馬上根據 Dockerfile 幫你 build 一個新的 image，要使用這個功能首先到 Docker Hub 右上角點選 Create Automated Build</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/69b4db75-9cce-4a0e-9431-9a2edbdeb00d/1_a5fqJARt4NHR5iQ194n0HA.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;">接著選 Github 或是 Bitbucket 告訴他你想幫哪個 repo 建立 Automated Build，我這邊是選我自己的 <a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a>，因為 build 需要 Dockerfile，如果你現在手上沒有任何專案有 Dockerfile 的話，可以 fork 我的專案跟著做做看</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/10c35c82-1837-437c-afd4-68136cdfff36/1_maboNuprETzshpSa5y_hgw.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;">給他一個 image 名字跟簡短的說明就可以了</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/3d3ace5a-702b-4a9e-a22d-9d8e02cee71e/1_GCN4sHYrtQ16gUX0oDVsHQ.png?t=1714610076"/></div><h2 class="heading" style="text-align:left;">設定觸發時機</h2><p class="paragraph" style="text-align:left;">新增完到 Build Settings 裡面看一下，現在有兩條規則：</p><p class="paragraph" style="text-align:left;">每次 master 有新的 commit 時就自動 build 一個 image:latest</p><p class="paragraph" style="text-align:left;">每次某個 branch 有新的 commit 時自動 build 一個 image:&lt;branch name&gt;</p><p class="paragraph" style="text-align:left;">基本上不需要去改他，除非你要做更進階的設定</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/2a1b7b60-58e5-4b1d-8099-d3376dbaf3de/1_kcovv9Q15OZboEOf-MRR-g.png?t=1714610077"/></div><h2 class="heading" style="text-align:left;">Push 新版本到 Github 上</h2><p class="paragraph" style="text-align:left;">Automated Build 已經設定完了，實際 push 一個新的 commit 到 Github 上，會看到 Build Details 裡面多了一個正在 build 的 image，之前說過只要有一樣的 Dockerfile，不管在哪裡 build 結果都會是一樣的，現在就是在 Docker 官方的主機上 Build</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/e34d4689-d704-4a9e-be91-10456d518372/1_3USzuGMyapba8qRhZbk1Jw.png?t=1714610077"/></div><h2 class="heading" style="text-align:left;">設定通知</h2><p class="paragraph" style="text-align:left;">如果在 build 的過程中發生了錯誤，那你應該會想收到通知吧？可以到<a class="link" href="https://hub.docker.com/settings/notifications?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">通知</a>這邊設定一下，發生錯誤的時候就會寄信跟你說</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/916d7bc0-a9bb-4a58-a87e-b7da5ea54891/1_rx2euCE6V_w27iGlDiKBuA.png?t=1714610077"/></div><p class="paragraph" style="text-align:left;">整個都設定完了之後就輕鬆了～以後只要有任何新的 code push 到 Github repo 上，Docker Hub 就會馬上 build 出一個新的 image，如果要在 server 上部屬的話直接從 Docker Hub 把它 pull 下來跑就可以了</p><h1 class="heading" style="text-align:left;">題外話</h1><p class="paragraph" style="text-align:left;">雖然 Docker Hub 上的 Automated Build 看起來很猛很方便 XD，但也是有缺點的，在 Docker Hub 上最多只能有一個私人專案，超過就不能再建立了</p><p class="paragraph" style="text-align:left;">但也不可能因此把私人或公司專案設公開，因為裡面有你的 code 還有 API_KEY 等等敏感資料，所以只能乖乖花錢買私人專案的額度，或是用其他免費的 docker registery 像是 <a class="link" href="https://canister.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">canister</a> 或是 <a class="link" href="https://treescale.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-2" target="_blank" rel="noopener noreferrer nofollow">treescale</a>，如果考量安全性的話也可以自己架，但就會稍微麻煩一點</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.beehiiv.com/?utm_campaign=87b7ed2c-0b24-4535-88a5-b3572d091ba5&utm_medium=post_rss&utm_source=william" target="_blank" rel="noopener noreferrer nofollow">Powered by beehiiv</a></p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=2d441586-79e5-41c2-9b39-055eb06f2fea&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>Docker 實戰系列(1)</title>
  <description>帶你 一步一步 dockerize 的應用</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/7ee0007b-6f70-4451-b55b-20e4506665bf/Docker_Cover.png" length="101441" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/docker-collection-application-1</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/docker-collection-application-1</guid>
  <pubDate>Fri, 05 Apr 2024 05:32:12 +0000</pubDate>
  <atom:published>2024-04-05T05:32:12Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Ai]]></category>
    <category><![CDATA[Program Coding]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:start;" id="docker-1-dockerize"><b>Docker 實戰系列（1）：帶你 一步一步 dockerize 的應用</b></h1><p class="paragraph" style="text-align:left;">想像一個情況，當你在本機開發完準備要部屬到自己的 server 上時，你發現 server 的系統不是你熟悉的 Ubuntu 而是 CentOS，除此之外你還需要自己安裝 php7、設定 MySQL 的帳號密碼跟架設 Apache，光想到要設定這些環境頭都痛了，這時候你就需要 Docker 了</p><p class="paragraph" style="text-align:left;">Docker 可以幫你把 Ubuntu + php7 + MySQL + Apache 的環境跟你的程式碼打包起來，整包丟到 CentOS的 server 上去跑，不用很勉強的在不熟悉的 CentOS 上配置環境，弄個不好說不定還會影響到其他正在跑的程式</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*ovRuAuqPf4r2xpiWh71rUg.png"/></div><h1 class="heading" style="text-align:left;" id="docker"><b>Docker 是什麼</b></h1><p class="paragraph" style="text-align:left;">Docker 是個輕量級的虛擬化技術，底層使用 cgroup、chroot、namespace 實作，可以<b>把你的應用程式連同環境一起打包</b>，部屬的時候就不用再擔心環境的問題</p><p class="paragraph" style="text-align:left;">下圖的例子就是使用 Docker 將三個已經打包起來的程式跑在不同的 container（容器）中，每個 container 都是一個獨立的環境，可以跑不同的系統跟安裝不同的資料庫、編譯器等等，意思就是說你可以 A 專案用 php5.3，另外一個用 php7，完全不會衝突</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*aMYtlKDuMsYxO-U7AM0A_g.png"/></div><h1 class="heading" style="text-align:left;" id="dockerize"><b>Dockerize</b></h1><p class="paragraph" style="text-align:left;">所謂的 dockerize 就是把你的應用程式 Docker 化，把你的程式跟環境包成一個 image，部屬的時候就直接使用這個 image 不需要額外安裝其他東西</p><h1 class="heading" style="text-align:left;"><b>事前準備</b></h1><p class="paragraph" style="text-align:left;">你可以使用自己最近在做的 side project，也許是一個用 Django 寫的 api server，或是用 Node.js 寫的爬蟲等等，手邊沒有 side project 的話我有寫一個簡單的 <span style="text-decoration:underline;"><a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a></span>，他會啟動一個 server 監聽 8080 port，到 <code>127.0.0.1:8080</code> 就可以看到 <code>Hello World!</code></p><h1 class="heading" style="text-align:left;" id="docker"><b>安裝 Docker</b></h1><p class="paragraph" style="text-align:left;">目前 Docker 有支援 Linux、Mac 跟 Windows，到 <span style="text-decoration:underline;"><a class="link" href="https://docs.docker.com/get-docker/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">Get Docker</a></span> 找到適合自己的版本，安裝完之後跑 <code>docker version</code>，有跑出版本就代表安裝成功了～</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*B2ROln3Or_zy0iA_UA52SQ.png"/></div><h1 class="heading" style="text-align:left;" id="docker-hub-pull-image"><b>從 Docker Hub 上 pull image</b></h1><p class="paragraph" style="text-align:left;">在 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/explore/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a></span> 上有很多官方的 image 可以直接拿來用，所謂的 image 就是一個已經打包好的環境，譬如說 Debian 或是 Ubuntu + Node.js 等等，需要這個環境時就可以直接把這個 image pull 下來用。</p><p class="paragraph" style="text-align:left;">使用 <code>docker pull ubuntu</code> 拿到最新的 ubuntu image，pull 的過程中會看到進度條</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*-Pgj0DD7r8Ap3Rl4KhVY_g.png"/></div><p class="paragraph" style="text-align:left;">完成後跑 <code>docker image ls</code> 就能看到有一個 ubuntu 的 image</p><div class="codeblock"><pre><code>REPOSITORY    TAG        IMAGE ID         CREATED         SIZE
ubuntu        latest     20c44cd7596f     2 weeks ago     123MB</code></pre></div><p class="paragraph" style="text-align:left;">接著 <code>docker run -it ubuntu bash</code>把 ubuntu 的 image 跑起來變成 container，<code>-it</code> 是為了讓我們進到這個 container 的 shell 下指令，進到 container 後跑跑看 <code>cat /etc/*release</code>，我這邊的版本是 <code>16.04.3 LTS</code></p><p class="paragraph" style="text-align:left;">到目前為止，我們已經可以在任何系統上用 Docker 跑 ubuntu 的環境了</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*BlyZYvUmxN-2RxGTCtidbw.png"/></div><p class="paragraph" style="text-align:left;">很多人看到這裡可能會有點搞混 image 跟 container，說明一下，image 指的是已經打包好的環境，但是還沒有跑起來，就是一堆檔案而已，而 container 則是把 image 跑起來之後產生的 instance，他們之間的關係就像「程式碼」跟「跑起來的程式」，程式碼不跑就只是一堆檔案，但跑起來之後他就會變成一個真的在跑 process</p><h1 class="heading" style="text-align:left;" id="dockerize"><b>開始 dockerize 你的應用程式</b></h1><p class="paragraph" style="text-align:left;">我們的終極目標是要<b>把你的程式碼跟想要的環境打包起來，變成一個 image</b>，之後不管到哪一台機器上，只要有裝 Docker 而且有這個 image 就可以把你的程式跑起來</p><p class="paragraph" style="text-align:left;">雖然程式有千百種，dockerize 的過程也不盡相同，但大致上可以分成這 6 個步驟，接下來會以上面提供的 <span style="text-decoration:underline;"><a class="link" href="https://github.com/Larry850806/simple-express-server?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">simple-express-server</a></span> 作為範例，大家可以視情況調整成適合自己應用的樣子</p><h2 class="heading" style="text-align:left;" id="step-0-dockerfile"><b>Step 0 — 新增 Dockerfile</b></h2><p class="paragraph" style="text-align:left;">為了把環境跟程式碼包成一個 image，我們需要一個 Dockerfile 把打包的步驟寫在裡面，先在專案目錄下新增一個空檔案叫做 Dockerfile</p><div class="codeblock"><pre><code>simple-express-server
├── Dockerfile   &lt;--   這裡
├── README.md
├── index.js
├── node_modules
└── package.json</code></pre></div><h2 class="heading" style="text-align:left;" id="step-1-base-image"><b>Step 1 — 找到適合的 base image</b></h2><p class="paragraph" style="text-align:left;">Docker 的 image 是一層一層疊加上去的，所以我們需要先在 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/explore/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">Docker Hub</a></span> 上選擇一個 base image，然後再慢慢把它加工成我們要的樣子</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:393/1*bKRHfz7unRA35WHd9SBOCA.png"/></div><p class="paragraph" style="text-align:left;">因為我這個專案是用 Node.js 寫的，所以我需要一個已經裝好 Node.js 的環境，有兩個選擇：</p><ol start="1"><li><p class="paragraph" style="text-align:left;">直接用 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/node/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">node</a></span> 作為我的 base image，裡面就已經有 Node.js 環境了</p></li><li><p class="paragraph" style="text-align:left;">用 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/ubuntu/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">ubuntu</a></span> 當 base image，再參考 <span style="text-decoration:underline;"><a class="link" href="https://nodejs.org/en/download/package-manager/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1#debian-and-ubuntu-based-linux-distributions" target="_blank" rel="noopener noreferrer nofollow">Installing</a></span> 把 node 裝在 ubuntu 上</p></li></ol><p class="paragraph" style="text-align:left;">因為第一種作法比較簡單，這邊就直接使用 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/node/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">node</a></span>，如果你是 <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/python/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">python</a></span>, <span style="text-decoration:underline;"><a class="link" href="https://hub.docker.com/_/golang/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1" target="_blank" rel="noopener noreferrer nofollow">golang</a></span> 等等其他語言也都可以找到相對應的 image，決定 base image 後就在 Dockerfile 的第一行寫 <code>FROM node:9.2.0</code>，<code>9.2.0</code> 指的是我們使用的 node image 版本，如果想要最新版的的話也可以指定 <code>node:latest</code></p><h2 class="heading" style="text-align:left;" id="step-2-copy"><b>Step 2 — copy 原始碼</b></h2><p class="paragraph" style="text-align:left;">有了 Node.js 環境之後要把 code 也包進去，這邊使用 <code>COPY</code> 指令，把 <code>index.js</code> 跟 <code>package.json</code> 複製到 <code>/app</code> 資料夾裡面</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:666/1*uoW4YWd7HSyE35e-hvl0wQ.png"/></div><h2 class="heading" style="text-align:left;" id="step-3-dependencies"><b>Step 3 — 安裝 dependencies</b></h2><p class="paragraph" style="text-align:left;">現在環境都配置好了，code 也已經在裡面了，我們要做的事情就是切換到 <code>/app</code> 這個目錄安裝 dependencies</p><p class="paragraph" style="text-align:left;">使用 <code>WORKDIR</code> 切換到 <code>/app</code> 目錄，再用 <code>RUN</code> 跑 <code>npm install &amp;&amp; npm cache clean --force</code>，清 npm cache 是為了讓 build 出來的 image 不要包含這些 cache，這樣 image 會小一點</p><p class="paragraph" style="text-align:left;">如果是其他語言就把 <code>npm install …</code> 換成其他指令就可以了，像 python 可能就是 <code>pip install …</code>，有 cache 的話記得要清一下</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*99L5tL38VLdYXrgpnnkxDQ.png"/></div><h2 class="heading" style="text-align:left;" id="step-4-initial-command"><b>Step 4 — 設定 initial command</b></h2><p class="paragraph" style="text-align:left;">現在環境、程式碼、dependencies 都準備好了，只剩把程式跑起來，這裡會用到 <span style="text-decoration:underline;"><a class="link" href="https://docs.docker.com/engine/reference/builder/?utm_source=beehiiv&utm_medium=William&utm_campaign=docker-1#cmd" target="_blank" rel="noopener noreferrer nofollow">CMD</a></span> 設定<b>這個 image 被跑起來時的預設指令</b>，對我這個程式來說要跑起來就是 <code>node index.js</code>，這樣就完成了 Dockerfile</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*03_4iaMIL223Z_-cx4Jryg.png"/></div><h2 class="heading" style="text-align:left;" id="step-5-build-image"><b>Step 5 — build 出 image</b></h2><p class="paragraph" style="text-align:left;">完成後就可以開始 build image，在專案目錄下跑 <code>docker build -t simple-express-server .</code> 就會根據 Dockerfile build 出你的 image</p><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*Twr5OWBUSu75OWElSiOIUQ.png"/></div><p class="paragraph" style="text-align:left;">build 完跑 <code>docker image ls</code> 可以看到多出一個 <code>simple-express-server</code>，這就是剛剛 build 出來的 image，裡面包含 node 的環境、程式碼還有 dependencies 跟預設啟動指令</p><div class="codeblock"><pre><code>REPOSITORY             TAG      IMAGE ID       CREATED        SIZE
simple-express-server  latest   dd05512eea91   2 minutes ago  677MB
ubuntu                 latest   20c44cd7596f   2 weeks ago    123MB</code></pre></div><h1 class="heading" style="text-align:left;" id="image"><b>把 image 跑起來</b></h1><p class="paragraph" style="text-align:left;">有了 image 後可以 <code>docker run -p 3000:8080 simple-express-server</code> 把 image 跑起來，在 container 內跑的就是剛剛設定的預設指令 <code>node index.js</code>，<code>-p 3000:8080</code> 則是把 container 內的 8080 port 跟外部的 3000 port 接通，如此一來只要用瀏覽器到 <code>127.0.0.1:3000</code> 就可以看到 <code>Hello World!</code>，這樣就完成 dockerize 了，現在你的電腦即便什麼都沒有只裝 docker 也可以把這個程式跑起來</p><h1 class="heading" style="text-align:left;"><b>跑在背景</b></h1><p class="paragraph" style="text-align:left;">如果照上面跑 <code>docker run -p 3000:8080 &lt;image&gt;</code> 的話會把終端機卡住，所以部屬的時候都會跑在背景，要跑在背景只要加一個 <code>-d</code> 就可以了，變成 <code>docker run -d &lt;image&gt;</code>，下指令後會得到一個 container ID，要看 log 的話可以跑 <code>docker logs &lt;container ID&gt;</code></p><h1 class="heading" style="text-align:left;" id="server-image"><b>server 上沒有這個 image 怎麼辦</b></h1><p class="paragraph" style="text-align:left;">因為現在是在本機 build，遠端的 server 還沒有這個 image，如果要部屬必須先把 image 傳到遠端的機器，但這樣很麻煩，比較好的方式是<b>把 Dockerfile 跟所有原始碼放在 git repo 裡面，直接在 server 上 build image</b>，因為都是照 Dockerfile 裡面的內容跑，所以不管是在自己電腦還是 server 上 build 結果都是一樣的</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=1479c6c6-a30f-4191-886a-4e3245f9ee07&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>A.I YOUTUBE</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2023/11/kittl-affiliatewilliam-0-150x150.jpg&quot; class=&quot;attachment-thumbnail</description>
  <link>https://affiliatewilliam.beehiiv.com/p/aiyoutube</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/aiyoutube</guid>
  <pubDate>Thu, 29 Feb 2024 03:53:30 +0000</pubDate>
  <atom:published>2024-02-29T03:53:30Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/8bce89a2-739f-4cfe-a561-1c8a2334d00f/kittl-affiliatewilliam-0-150x150.jpg?t=1714610072"/></div><p class="paragraph" style="text-align:left;"></p><div class="image"><img class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/6047e2eb-1fcf-4f37-91e4-a86c896e1a42/kittl-affiliatewilliam-3.jpg?t=1714610073"/></div><p class="paragraph" style="text-align:left;">Youtube 分享教學 / 實用工具 / 理財</p><p class="paragraph" style="text-align:left;"></p><div class="image"><img class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/38930984-dbe6-43df-a733-80d665efe2e6/She-believed-she-could-so-she-did.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;">A.I 圖像工具 + 影片工具</p><p class="paragraph" style="text-align:left;"></p><h2 class="heading" style="text-align:left;">為什麼別人家的 ChatGPT 這麼聰明，我們家的整天跟我雞同鴨講？？搞懂「提示工程」讓你成為專業的 AI 溝通師！</h2><p class="paragraph" style="text-align:left;">我們家免費提供 300 ChatGPT Social Media Analytics Prompts</p><ul><li><p class="paragraph" style="text-align:left;">Engagement Metrics</p></li><li><p class="paragraph" style="text-align:left;">Reach Metrics</p></li><li><p class="paragraph" style="text-align:left;">Conversion Metrics</p></li><li><p class="paragraph" style="text-align:left;">Sentiment Analysis</p></li><li><p class="paragraph" style="text-align:left;">Competitive Analysis</p></li><li><p class="paragraph" style="text-align:left;">Content Analysis</p></li><li><p class="paragraph" style="text-align:left;">Influencer Analysis</p></li><li><p class="paragraph" style="text-align:left;">Audience Analysis</p></li><li><p class="paragraph" style="text-align:left;">Campaign Analysis</p></li><li><p class="paragraph" style="text-align:left;">Data Visualization</p></li><li><p class="paragraph" style="text-align:left;">User Behavior Analysis</p></li><li><p class="paragraph" style="text-align:left;">Hashtag Analysis</p></li><li><p class="paragraph" style="text-align:left;">Platform-Specific Analytics</p></li><li><p class="paragraph" style="text-align:left;">Crisis Management</p></li><li><p class="paragraph" style="text-align:left;">Return on Investment (ROI) Analysis</p></li></ul><h2 class="heading" style="text-align:left;">專業 A.I 圖像生成及影片生成，我們家一樣有更多專業工具提供，只要您留下的個人基本資訊，能快速地實現 A.I 未來領域創造自己的 A.I 品牌。</h2></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=1fc35e38-c240-4844-97d0-ca7a78ba16b1&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>2024 年 10 大 Power BI 儀表板範例</title>
  <description>數據視覺化對於數據分析至關重要,有助於用戶建立報告和儀表板來分析各種來源的數據。</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/8fbfaa11-8872-42c9-8d8a-84d082c72a09/mokkupai.png" length="256510" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/top-10-power-bi-dashboard-examples-in-2024</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/top-10-power-bi-dashboard-examples-in-2024</guid>
  <pubDate>Tue, 30 Jan 2024 00:51:28 +0000</pubDate>
  <atom:published>2024-01-30T00:51:28Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:start;" id="2024-10-power-bi"><b>2024 年 10 大 Power BI 儀表板範例</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*qSYVUTp5VIqM0koy"/></div><p class="paragraph" style="text-align:start;">數據視覺化對於數據分析至關重要，有助於用戶建立報告和儀表板來分析各種來源的數據。 Microsoft 的 Power BI（商業智慧工具）說明了這種功能。</p><p class="paragraph" style="text-align:start;">透過簡單的介面提供使用者友善的商業智慧功能和自訂視覺效果是 Power BI 儀表板的目標。借助這些工具，最終用戶可以輕鬆建立儀表板和報告。作為 Microsoft Power Platform 的一部分，它們可以與其他 Microsoft 技術很好地配合。這使得從客戶資料中獲取有用資訊變得更加容易。</p><h1 class="heading" style="text-align:start;"><b>目錄</b></h1><ul><li><p class="paragraph" style="text-align:left;"><span style="text-decoration:underline;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_45160248845201703847928311" target="_blank" rel="noopener noreferrer nofollow">Power BI 簡介</a></span></p></li><li><p class="paragraph" style="text-align:left;"><span style="text-decoration:underline;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_58702581146821703847936744" target="_blank" rel="noopener noreferrer nofollow">Power BI 的用途</a></span></p></li><li><p class="paragraph" style="text-align:left;"><span style="text-decoration:underline;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_57865358848781703847945558" target="_blank" rel="noopener noreferrer nofollow">Power BI 的主要功能</a></span></p></li><li><p class="paragraph" style="text-align:left;"><span style="text-decoration:underline;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_5307463750381703847952891" target="_blank" rel="noopener noreferrer nofollow">十大 Power BI 儀表板範例</a></span></p></li></ul><h1 class="heading" style="text-align:start;" id="power-bi"><b>Power BI 簡介</b></h1><p class="paragraph" style="text-align:start;">Microsoft Power BI 作為<span style="text-decoration:underline;"><a class="link" href="https://www.mokkup.ai/blogs/what-is-data-visualization/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">資料視覺化</a></span>平台，主要滿足商業智慧需求。具有不同資料能力等級的業務專業人員使用 Power BI 儀表板來滿足他們的需求。它以各種格式有效地呈現和視覺化數據，包括圖表、圖形、地圖和散點圖。此外，其「AI Insights」工具使用人工智慧在資料集中為消費者尋找見解。</p><p class="paragraph" style="text-align:start;">Power BI 服務包含多個互連的應用程式：Power BI Desktop、Pro、Premium、Mobile、Embedded 和 Report Server。雖然有些是免費的，但訂閱專業版和高級版可提供增強的分析功能。</p><p class="paragraph" style="text-align:start;">Power BI 是一種低程式碼工具。它是微軟 Power Platform 的一部分。 Power Platform 還包括 Power Apps、Power Pages、Power Automate 等。這些應用程式可協助企業進行資料分析、視覺化、制定業務解決方案、自動化流程和開發聊天機器人，而無需廣泛的編碼專業知識。</p><p class="paragraph" style="text-align:start;">資料分析師依賴 Power BI 報表伺服器進行安全的本機報表管理。借助 Power BI Mobile，他們可以立即存取這些報告並與之交互，從而隨時隨地快速做出明智的決策。</p><h1 class="heading" style="text-align:start;" id="power-bi"><b>Power BI 的用途</b></h1><p class="paragraph" style="text-align:start;">使用 Microsoft Power BI，人們可以檢查組織的資料以獲得見解。透過使用Power BI，可以連結不相關的資料集，清理資料並將其修改為資料模型，並建立直觀地顯示資料的圖形或圖表。</p><p class="paragraph" style="text-align:start;">組織可以透過多種方式使用 Power BI 建立的資料模型，其中包括：</p><ul><li><p class="paragraph" style="text-align:left;">使用數據視覺化來講述故事。</p></li><li><p class="paragraph" style="text-align:left;">探索資料中的假設場景。</p></li><li><p class="paragraph" style="text-align:left;">產生即時報告來解決查詢並幫助預測，以確保部門與業務指標保持一致。</p></li></ul><p class="paragraph" style="text-align:start;">此外，Power BI 為管理員或經理提供了便利的執行儀表板，提供對部門績效的增強洞察，以製定數據驅動的決策。</p><h1 class="heading" style="text-align:start;" id="power-bi"><b>Power BI 的主要功能</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*39oYMbSKx3qUeQbi.png"/></div><p class="paragraph" style="text-align:start;">Microsoft 為 Power BI 新增了各種資料分析功能。一些最重要的功能如下：</p><ul><li><p class="paragraph" style="text-align:left;">人工智慧：Power BI 使用者可以透過使用自動化機器學習功能、文字分析和圖像辨識來建立機器學習模型。與 Azure 機器學習的整合進一步增強了這些功能。</p></li><li><p class="paragraph" style="text-align:left;">混合部署支援：它提供內建連接器，可讓 Power BI 工具連接來自 Microsoft、Salesforce 和其他供應商的各種資料來源。</p></li><li><p class="paragraph" style="text-align:left;">通用資料模型支援：通用資料模型允許使用標準化資料結構。這些結構包括實體、屬性和關係。所有使用者都可以存取這些標準化資料結構。</p></li><li><p class="paragraph" style="text-align:left;">Cortana 整合：此功能在行動裝置上特別受歡迎，它使用戶能夠以自然語言查詢數據，並利用 Microsoft 的數位助理 Cortana 檢索回應。</p></li><li><p class="paragraph" style="text-align:left;">API 整合：此功能可為開發人員提供應用程式介面 (API) 和範例程式碼，以便他們可以將 Power BI 儀表板合併到其他軟體解決方案中。</p></li></ul><h1 class="heading" style="text-align:start;" id="power-bi"><b>十大 Power BI 儀表板範例</b></h1><p class="paragraph" style="text-align:start;">讓我們來看看下面討論的各種 Power BI 儀表板範例：</p><h1 class="heading" style="text-align:start;" id="1"><b>1.人力資源分析：</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*CyKCjsU9Fz5yHXUE.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/HR-Analytics/m-p/3369774?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">在 Power BI 上建立的HR Analytics</a></span>儀表板是一個互動式儀表板，顯示公司的關鍵 HR 指標。儀表板包括一個摘要頁面，提供關鍵績效指標 (KPI) 的概述。此外，它還包含單獨的頁面，可以更深入地研究員工詳細資訊、終止和招聘統計數據。</p><h1 class="heading" style="text-align:start;" id="2"><b>2. 財務投訴概述</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*zgaTYisO1-VVcHYX.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Financial-Consumer-Complaints/td-p/3562357?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">使用 Microsoft Power BI 建立的財務投訴</a></span>概覽儀表板可全面洞察關鍵績效指標 (KPI)，例如整體投訴計數、及時回應、持續投訴、爭議率和免費解決方案。</p><p class="paragraph" style="text-align:start;">Power BI 儀表板設計顯示按問題、位置、媒體和產品排序的投訴詳細資訊以及消費者糾紛的百分比。它還為用戶提供有關組織財務績效的詳細資訊。</p><h1 class="heading" style="text-align:start;" id="3"><b>3. 銀幕金獎時代</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*03xpZkibTJKBqa6X.png"/></div><p class="paragraph" style="text-align:start;">Power BI 儀表板「<span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Workout-Wednesday-2023-Week-47-Power-BI-Use-the-New-Button/td-p/3541283?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">銀幕金獎時代</a></span>」概述了個人獲得奧斯卡最佳男主角、女演員或導演獎的年齡。每個點都像徵著一位獲獎者。</p><p class="paragraph" style="text-align:start;">點的垂直位置代表個人的年齡，而水平位置則表示相應頒獎典禮的日期。</p><h1 class="heading" style="text-align:start;" id="4"><b>4. 零售案例分析</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*lNPXoIfNtpqKlCHW.png"/></div><p class="paragraph" style="text-align:start;">零售<span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Retail-Case-Analysis/td-p/3541055?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">案例分析</a></span>銷售儀表板提供三個全面的視圖 - 概述、通路分析和財務。它顯示了總銷售額、利潤、利潤和銷售數量。</p><p class="paragraph" style="text-align:start;">此儀表板提供了用於銷售的管道（例如線上、店內和專賣店）的全面分析。第三個視圖包括全面的財務分析，其中包含銷售額、營業利潤、營業利潤率等詳細資訊。</p><h1 class="heading" style="text-align:start;" id="5"><b>5. 工作場所的多元化和包容性</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*6hB6HuF5RptmHwcK.png"/></div><p class="paragraph" style="text-align:start;">Power BI<span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Diversity-and-inclusion-at-workplace-Dashboard/td-p/3517108?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">工作場所多元化和包容性</a></span>儀表板提供了組織內男性和女性員工分佈的概覽。</p><p class="paragraph" style="text-align:start;">儀表板顯示各領域的多樣性。這些領域包括年齡、員工狀況、職位等級、部門、國籍和晉升。儀表板顯示了當前和往年的多樣性。</p><h1 class="heading" style="text-align:start;" id="6"><b>6. 人力資源流失洞察－案例研究</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*y76y0LJAokW6NVNr.png"/></div><p class="paragraph" style="text-align:start;">HR <span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/HR-Attrition-Insights-Case-Study/td-p/3465746?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">Attrition Insights</a></span>儀表板顯示員工總數、離開公司的員工人數以及按性別分類的員工流失百分比。</p><p class="paragraph" style="text-align:start;">此外，儀表板還提供了一項調查的概述，展示了員工流失的各種原因。</p><h1 class="heading" style="text-align:start;" id="7"><b>7. 醫療保健支出</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*UscroAj1F53ueM0G.png"/></div><p class="paragraph" style="text-align:start;">「<span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Healthcare-Expenditure/td-p/3437485?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">醫療保健支出</a></span>」Power BI 儀表板顯示了醫療保健支出佔國家 GDP 的百分比。它提供了 GDP 百分比詳細資訊、平均值、分佈、國家/地區細分和基於年份的 GDP 百分比聚類的見解。</p><p class="paragraph" style="text-align:start;">此外，它還可以對不同年份和集群的 GDP 百分比進行比較分析。此儀表板有助於了解不同國家隨時間推移的醫療保健支出相對於國家 GDP 的趨勢。</p><h1 class="heading" style="text-align:start;" id="8"><b>8. 超市績效報告</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*0iEY1rpEHWD2xPvl.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Superstore-Perfomance-Report-Dark-and-Light-dynamic-theme/td-p/3414526?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">Power BI 中的Superstore 績效報告</a></span>顯示了包括收入、客戶、利潤和交易在內的關鍵指標。它還提供了跨類別、細分市場和國家的收入比較。</p><p class="paragraph" style="text-align:start;">此外，儀表板還顯示家具、辦公用品、技術、消費者、企業和家庭辦公部門的收入波動，與前一年進行比較。這提供了對特定產品類別和客戶群有關收入同比變化的洞察。</p><h1 class="heading" style="text-align:start;" id="9"><b>9. 網路研討會分析</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*YqaQfVj8eWkaKolV9LhLZg.png"/></div><p class="paragraph" style="text-align:start;">網路研討會分析儀表板範本編譯並呈現從網路研討會績效中得出的關鍵指標和見解。它提供了兩個全面的視圖——“網路研討會相關數據摘要”和“參與度視圖”，包括註冊、出席、參與度指標、觀眾互動和其他基本指標。</p><p class="paragraph" style="text-align:start;">此儀表板有助於評估網路研討會的有效性，確定成功的策略，並為未來的網路研討會計劃制定數據驅動的決策。</p><h1 class="heading" style="text-align:start;" id="10-gartner"><b>10. 在歐洲、中東和非洲 Gartner 資料與分析高峰會上分析聯合國永續發展目標</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/0*hmeDPz9XWw0qoH9M.png"/></div><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Analyzing-the-UN-s-Sustainable-Development-Goals-at-Gartner-Data/td-p/2527235?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">永續發展目標</a></span>儀表板包含四個視角：電力供應、GDP 二氧化碳排放量、二氧化碳驅動因素和歸因。它概述了全球電力供應情況，詳細介紹了多年來獲得電力供應和缺乏電力供應的地區。此外，它還比較了城市和農村地區的電力供應。</p><p class="paragraph" style="text-align:start;">GDP 二氧化碳排放量儀表板顯示了 GDP 和二氧化碳排放量之間的關係和相互影響。</p><h1 class="heading" style="text-align:start;" id="mokkup"><b>Mokkup 的免費範本（銷售與庫存報告）</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*7GrYuNfrkXNgJ398bYKtDg.png"/></div><p class="paragraph" style="text-align:start;">使用 Mokkup.ai 建立的銷售與庫存報告線框展示了組織內的庫存概覽。它深入探討庫存水準過剩和不足，概述非流通產品，並重點介紹零庫存的快速流通產品。</p><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://www.mokkup.ai/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">Mokkup.ai</a></span>是一款儀表板線框圖工具，可提供跨產業選項的可自訂範本。您可以從頭開始構建，也可以從預先建置的範本中進行選擇。使用 Mokkup.ai，您可以建立線框，幫助您視覺化並實現最終設計。</p><p class="paragraph" style="text-align:start;">它還提供「即時示範」功能，可讓您預覽 Tableau 和 Power BI 儀表板格式的儀表板線框。</p><h1 class="heading" style="text-align:start;"><b>結論</b></h1><p class="paragraph" style="text-align:start;">Power BI 儀表板範例和資源示範了資料視覺化如何將非結構化資料轉換為有價值且可操作的見解。這有助於決策者做出明智的選擇並提高組織的成功。</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=3cc06f6c-50c7-4ac2-ad99-ce45d60d8161&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>2024 年 10 大 Power BI 儀表板範例</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2024/01/mokkupai-150x150.png&quot; class=&quot;attachment-thumbnail size-thumbnail </description>
  <link>https://affiliatewilliam.beehiiv.com/p/2024-e5-b9-b4-10-e5-a4-a7-power-bi-e5-84-80-e8-a1-a8-e6-9d-bf-e7-af-84-e4-be-8b</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/2024-e5-b9-b4-10-e5-a4-a7-power-bi-e5-84-80-e8-a1-a8-e6-9d-bf-e7-af-84-e4-be-8b</guid>
  <pubDate>Tue, 30 Jan 2024 00:51:28 +0000</pubDate>
  <atom:published>2024-01-30T00:51:28Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/c4101de9-47b2-438f-add6-f9baf0ec04da/mokkupai-150x150.png?t=1714610075"/></div><h1 class="heading" style="text-align:left;">2024 年 10 大 Power BI 儀表板範例</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/7050a75f-9934-433e-8d2b-c4bfe57d5dd0/0_qSYVUTp5VIqM0koy.png?t=1714610075"/></div><p class="paragraph" style="text-align:left;">數據視覺化對於數據分析至關重要，有助於用戶建立報告和儀表板來分析各種來源的數據。 Microsoft 的 Power BI（商業智慧工具）說明了這種功能。</p><p class="paragraph" style="text-align:left;">透過簡單的介面提供使用者友善的商業智慧功能和自訂視覺效果是 Power BI 儀表板的目標。借助這些工具，最終用戶可以輕鬆建立儀表板和報告。作為 Microsoft Power Platform 的一部分，它們可以與其他 Microsoft 技術很好地配合。這使得從客戶資料中獲取有用資訊變得更加容易。</p><h1 class="heading" style="text-align:left;">目錄</h1><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_45160248845201703847928311" target="_blank" rel="noopener noreferrer nofollow">Power BI 簡介</a></p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_58702581146821703847936744" target="_blank" rel="noopener noreferrer nofollow">Power BI 的用途</a></p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_57865358848781703847945558" target="_blank" rel="noopener noreferrer nofollow">Power BI 的主要功能</a></p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.mokkup.ai/blogs/top-10-power-bi-dashboard-examples-in-2024/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi#h_5307463750381703847952891" target="_blank" rel="noopener noreferrer nofollow">十大 Power BI 儀表板範例</a></p><h1 class="heading" style="text-align:left;">Power BI 簡介</h1><p class="paragraph" style="text-align:left;">Microsoft Power BI 作為<a class="link" href="https://www.mokkup.ai/blogs/what-is-data-visualization/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">資料視覺化</a>平台，主要滿足商業智慧需求。具有不同資料能力等級的業務專業人員使用 Power BI 儀表板來滿足他們的需求。它以各種格式有效地呈現和視覺化數據，包括圖表、圖形、地圖和散點圖。此外，其「AI Insights」工具使用人工智慧在資料集中為消費者尋找見解。</p><p class="paragraph" style="text-align:left;">Power BI 服務包含多個互連的應用程式：Power BI Desktop、Pro、Premium、Mobile、Embedded 和 Report Server。雖然有些是免費的，但訂閱專業版和高級版可提供增強的分析功能。</p><p class="paragraph" style="text-align:left;">Power BI 是一種低程式碼工具。它是微軟 Power Platform 的一部分。 Power Platform 還包括 Power Apps、Power Pages、Power Automate 等。這些應用程式可協助企業進行資料分析、視覺化、制定業務解決方案、自動化流程和開發聊天機器人，而無需廣泛的編碼專業知識。</p><p class="paragraph" style="text-align:left;">資料分析師依賴 Power BI 報表伺服器進行安全的本機報表管理。借助 Power BI Mobile，他們可以立即存取這些報告並與之交互，從而隨時隨地快速做出明智的決策。</p><h1 class="heading" style="text-align:left;">Power BI 的用途</h1><p class="paragraph" style="text-align:left;">使用 Microsoft Power BI，人們可以檢查組織的資料以獲得見解。透過使用Power BI，可以連結不相關的資料集，清理資料並將其修改為資料模型，並建立直觀地顯示資料的圖形或圖表。</p><p class="paragraph" style="text-align:left;">組織可以透過多種方式使用 Power BI 建立的資料模型，其中包括：</p><p class="paragraph" style="text-align:left;">使用數據視覺化來講述故事。</p><p class="paragraph" style="text-align:left;">探索資料中的假設場景。</p><p class="paragraph" style="text-align:left;">產生即時報告來解決查詢並幫助預測，以確保部門與業務指標保持一致。</p><p class="paragraph" style="text-align:left;">此外，Power BI 為管理員或經理提供了便利的執行儀表板，提供對部門績效的增強洞察，以製定數據驅動的決策。</p><h1 class="heading" style="text-align:left;">Power BI 的主要功能</h1><p class="paragraph" style="text-align:left;">Microsoft 為 Power BI 新增了各種資料分析功能。一些最重要的功能如下：</p><p class="paragraph" style="text-align:left;">人工智慧：Power BI 使用者可以透過使用自動化機器學習功能、文字分析和圖像辨識來建立機器學習模型。與 Azure 機器學習的整合進一步增強了這些功能。</p><p class="paragraph" style="text-align:left;">混合部署支援：它提供內建連接器，可讓 Power BI 工具連接來自 Microsoft、Salesforce 和其他供應商的各種資料來源。</p><p class="paragraph" style="text-align:left;">通用資料模型支援：通用資料模型允許使用標準化資料結構。這些結構包括實體、屬性和關係。所有使用者都可以存取這些標準化資料結構。</p><p class="paragraph" style="text-align:left;">Cortana 整合：此功能在行動裝置上特別受歡迎，它使用戶能夠以自然語言查詢數據，並利用 Microsoft 的數位助理 Cortana 檢索回應。</p><p class="paragraph" style="text-align:left;">API 整合：此功能可為開發人員提供應用程式介面 (API) 和範例程式碼，以便他們可以將 Power BI 儀表板合併到其他軟體解決方案中。</p><h1 class="heading" style="text-align:left;">十大 Power BI 儀表板範例</h1><p class="paragraph" style="text-align:left;">讓我們來看看下面討論的各種 Power BI 儀表板範例：</p><h1 class="heading" style="text-align:left;">1.人力資源分析：</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/70e86ae6-8eb3-4a15-88d6-cdbfb04fd090/0_CyKCjsU9Fz5yHXUE.png?t=1714610075"/></div><p class="paragraph" style="text-align:left;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/HR-Analytics/m-p/3369774?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">在 Power BI 上建立的HR Analytics</a>儀表板是一個互動式儀表板，顯示公司的關鍵 HR 指標。儀表板包括一個摘要頁面，提供關鍵績效指標 (KPI) 的概述。此外，它還包含單獨的頁面，可以更深入地研究員工詳細資訊、終止和招聘統計數據。</p><h1 class="heading" style="text-align:left;">2. 財務投訴概述</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/0152c671-fd71-4fd4-b0ec-25a7610e8848/0_zgaTYisO1-VVcHYX.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Financial-Consumer-Complaints/td-p/3562357?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">使用 Microsoft Power BI 建立的財務投訴</a>概覽儀表板可全面洞察關鍵績效指標 (KPI)，例如整體投訴計數、及時回應、持續投訴、爭議率和免費解決方案。</p><p class="paragraph" style="text-align:left;">Power BI 儀表板設計顯示按問題、位置、媒體和產品排序的投訴詳細資訊以及消費者糾紛的百分比。它還為用戶提供有關組織財務績效的詳細資訊。</p><h1 class="heading" style="text-align:left;">3. 銀幕金獎時代</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/b13eb302-e43d-4105-9b3c-e92b6070d890/0_03xpZkibTJKBqa6X.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;">Power BI 儀表板「<a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Workout-Wednesday-2023-Week-47-Power-BI-Use-the-New-Button/td-p/3541283?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">銀幕金獎時代</a>」概述了個人獲得奧斯卡最佳男主角、女演員或導演獎的年齡。每個點都像徵著一位獲獎者。</p><p class="paragraph" style="text-align:left;">點的垂直位置代表個人的年齡，而水平位置則表示相應頒獎典禮的日期。</p><h1 class="heading" style="text-align:left;">4. 零售案例分析</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/16f72d76-e5c1-48d8-aa77-917314454d74/0_lNPXoIfNtpqKlCHW.png?t=1714610076"/></div><p class="paragraph" style="text-align:left;">零售<a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Retail-Case-Analysis/td-p/3541055?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">案例分析</a>銷售儀表板提供三個全面的視圖 – 概述、通路分析和財務。它顯示了總銷售額、利潤、利潤和銷售數量。</p><p class="paragraph" style="text-align:left;">此儀表板提供了用於銷售的管道（例如線上、店內和專賣店）的全面分析。第三個視圖包括全面的財務分析，其中包含銷售額、營業利潤、營業利潤率等詳細資訊。</p><h1 class="heading" style="text-align:left;">5. 工作場所的多元化和包容性</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/25eafad0-d1ac-4c1a-8cb2-233a42d28cab/0_6hB6HuF5RptmHwcK.png?t=1714610077"/></div><p class="paragraph" style="text-align:left;">Power BI<a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Diversity-and-inclusion-at-workplace-Dashboard/td-p/3517108?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">工作場所多元化和包容性</a>儀表板提供了組織內男性和女性員工分佈的概覽。</p><p class="paragraph" style="text-align:left;">儀表板顯示各領域的多樣性。這些領域包括年齡、員工狀況、職位等級、部門、國籍和晉升。儀表板顯示了當前和往年的多樣性。</p><h1 class="heading" style="text-align:left;">6. 人力資源流失洞察－案例研究</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/70cc4946-6f48-4453-b9a3-5fc3c8b5537f/0_y76y0LJAokW6NVNr.png?t=1714610079"/></div><p class="paragraph" style="text-align:left;">HR <a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/HR-Attrition-Insights-Case-Study/td-p/3465746?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">Attrition Insights</a>儀表板顯示員工總數、離開公司的員工人數以及按性別分類的員工流失百分比。</p><p class="paragraph" style="text-align:left;">此外，儀表板還提供了一項調查的概述，展示了員工流失的各種原因。</p><h1 class="heading" style="text-align:left;">7. 醫療保健支出</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/a34da490-613e-45d4-8a97-71ecffec07fe/0_UscroAj1F53ueM0G.png?t=1714610081"/></div><p class="paragraph" style="text-align:left;">「<a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Healthcare-Expenditure/td-p/3437485?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">醫療保健支出</a>」Power BI 儀表板顯示了醫療保健支出佔國家 GDP 的百分比。它提供了 GDP 百分比詳細資訊、平均值、分佈、國家/地區細分和基於年份的 GDP 百分比聚類的見解。</p><p class="paragraph" style="text-align:left;">此外，它還可以對不同年份和集群的 GDP 百分比進行比較分析。此儀表板有助於了解不同國家隨時間推移的醫療保健支出相對於國家 GDP 的趨勢。</p><h1 class="heading" style="text-align:left;">8. 超市績效報告</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/50fb6632-45c9-48a3-85e6-259b8f6cb4a1/0_0iEY1rpEHWD2xPvl.png?t=1714610082"/></div><p class="paragraph" style="text-align:left;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Superstore-Perfomance-Report-Dark-and-Light-dynamic-theme/td-p/3414526?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">Power BI 中的Superstore 績效報告</a>顯示了包括收入、客戶、利潤和交易在內的關鍵指標。它還提供了跨類別、細分市場和國家的收入比較。</p><p class="paragraph" style="text-align:left;">此外，儀表板還顯示家具、辦公用品、技術、消費者、企業和家庭辦公部門的收入波動，與前一年進行比較。這提供了對特定產品類別和客戶群有關收入同比變化的洞察。</p><h1 class="heading" style="text-align:left;">9. 網路研討會分析</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/04b13842-c77c-428b-8cf9-a7fad1665fa9/1_YqaQfVj8eWkaKolV9LhLZg.png?t=1714610082"/></div><p class="paragraph" style="text-align:left;">網路研討會分析儀表板範本編譯並呈現從網路研討會績效中得出的關鍵指標和見解。它提供了兩個全面的視圖——“網路研討會相關數據摘要”和“參與度視圖”，包括註冊、出席、參與度指標、觀眾互動和其他基本指標。</p><p class="paragraph" style="text-align:left;">此儀表板有助於評估網路研討會的有效性，確定成功的策略，並為未來的網路研討會計劃制定數據驅動的決策。</p><h1 class="heading" style="text-align:left;">10. 在歐洲、中東和非洲 Gartner 資料與分析高峰會上分析聯合國永續發展目標</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ed353148-6da7-4969-a74e-f50bfdacfa9f/0_hmeDPz9XWw0qoH9M.png?t=1714610083"/></div><p class="paragraph" style="text-align:left;"><a class="link" href="https://community.fabric.microsoft.com/t5/Data-Stories-Gallery/Analyzing-the-UN-s-Sustainable-Development-Goals-at-Gartner-Data/td-p/2527235?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">永續發展目標</a>儀表板包含四個視角：電力供應、GDP 二氧化碳排放量、二氧化碳驅動因素和歸因。它概述了全球電力供應情況，詳細介紹了多年來獲得電力供應和缺乏電力供應的地區。此外，它還比較了城市和農村地區的電力供應。</p><p class="paragraph" style="text-align:left;">GDP 二氧化碳排放量儀表板顯示了 GDP 和二氧化碳排放量之間的關係和相互影響。</p><h1 class="heading" style="text-align:left;">Mokkup 的免費範本（銷售與庫存報告）</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/adc3ed46-cab5-413b-9a3f-58eb7d0d23a6/1_7GrYuNfrkXNgJ398bYKtDg.png?t=1714610083"/></div><p class="paragraph" style="text-align:left;">使用 Mokkup.ai 建立的銷售與庫存報告線框展示了組織內的庫存概覽。它深入探討庫存水準過剩和不足，概述非流通產品，並重點介紹零庫存的快速流通產品。</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.mokkup.ai/?utm_source=beehiiv&utm_medium=William&utm_campaign=2024-10-power-bi" target="_blank" rel="noopener noreferrer nofollow">Mokkup.ai</a>是一款儀表板線框圖工具，可提供跨產業選項的可自訂範本。您可以從頭開始構建，也可以從預先建置的範本中進行選擇。使用 Mokkup.ai，您可以建立線框，幫助您視覺化並實現最終設計。</p><p class="paragraph" style="text-align:left;">它還提供「即時示範」功能，可讓您預覽 Tableau 和 Power BI 儀表板格式的儀表板線框。</p><h1 class="heading" style="text-align:left;">結論</h1><p class="paragraph" style="text-align:left;">Power BI 儀表板範例和資源示範了資料視覺化如何將非結構化資料轉換為有價值且可操作的見解。這有助於決策者做出明智的選擇並提高組織的成功。</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.beehiiv.com/?utm_campaign=3cc06f6c-50c7-4ac2-ad99-ce45d60d8161&utm_medium=post_rss&utm_source=william" target="_blank" rel="noopener noreferrer nofollow">Powered by beehiiv</a></p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=d137030e-97c8-4e28-a39a-4909cd3d8f90&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>使用 Python 抓取 Google 搜尋結果 (2024)</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2024/01/scraping-google-search-results-using-python-xzSHSo-150x150.png&quot; c</description>
  <link>https://affiliatewilliam.beehiiv.com/p/e4-bd-bf-e7-94-a8-python-e6-8a-93-e5-8f-96-google-e6-90-9c-e5-b0-8b-e7-b5-90-e6-9e-9c-2024</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/e4-bd-bf-e7-94-a8-python-e6-8a-93-e5-8f-96-google-e6-90-9c-e5-b0-8b-e7-b5-90-e6-9e-9c-2024</guid>
  <pubDate>Mon, 22 Jan 2024 16:01:00 +0000</pubDate>
  <atom:published>2024-01-22T16:01:00Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/0ffbcffb-e876-4fa1-9f05-204488e46c86/scraping-google-search-results-using-python-xzSHSo-150x150.png?t=1714610081"/></div><h1 class="heading" style="text-align:left;">使用 Python 抓取 Google 搜尋結果 ( 2024)</h1><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ea6d183b-4bc0-43bb-b3d8-40d52e957b24/scraping-google-search-results-using-python.png?t=1714610083"/></div><p class="paragraph" style="text-align:left;">Python程式語言由Guido van Rossum於1991年開發，主要強調程式碼的可讀性和清晰簡潔的語法。</p><p class="paragraph" style="text-align:left;">本教學將教我們使用 Python 抓取 Google 搜尋結果。Python 在以下領域獲得了廣泛的流行網頁抓取由於可讀性、可擴展性等優勢，它成為了一個社群。這使得它成為其他程式語言的絕佳替代品，也是網頁抓取任務的完美選擇。</p><p class="paragraph" style="text-align:left;">這篇部落格文章不僅將重點放在 Google 資料抓取，還將讓您清楚地了解為什麼 Python 是從 Google 提取資料的最佳選擇，以及從 Google 收集資訊的好處有哪些。</p><p class="paragraph" style="text-align:left;">我們將使用HTTPX和BS4來抓取和解析原始 HTML 資料。 </p><p class="paragraph" style="text-align:left;">閱讀本文後，您將對使用 Python 抓取 Google 搜尋結果有基本的了解。您還可以利用這些知識來使用其他程式語言進行未來的網頁抓取專案。</p><h2 class="heading" style="text-align:left;">為什麼要用 Python 來抓取 Google 資料？</h2><p class="paragraph" style="text-align:left;">Python 是一種健全而強大的語言，非常重視其程式碼的可讀性和清晰度。這使得初學者能夠快速輕鬆地學習和實現抓取腳本。它還擁有一個龐大且活躍的開發人員社區，如果您的程式碼出現任何問題，他們可以為您提供幫助。</p><p class="paragraph" style="text-align:left;">使用 Python 的另一個優點是，它提供了專門為從 Web 抓取資料而設計的各種框架和程式庫，包括 Scrapy、BeautifulSoup、Playwright 和 Selenium。</p><p class="paragraph" style="text-align:left;">總的來說，Python 提供了許多優勢，例如高效能、可擴展性和各種其他抓取資源。這使得它不僅成為從 Google 提取資料的絕佳選擇，而且也適用於其他網頁抓取任務。</p><h2 class="heading" style="text-align:left;">使用 Python 抓取 Google 搜尋結果</h2><p class="paragraph" style="text-align:left;">在這篇文章中，我們將建立一個基本的 Python 腳本來抓取前十個 Google 搜尋結果，包括它們的標題、描述和連結。</p><h3 class="heading" style="text-align:left;">設定</h3><p class="paragraph" style="text-align:left;">對於那些尚未在其設備上安裝 Python 的用戶，請考慮以下影片：</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.youtube.com/watch?v=yivyNCtVVDk&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">如何在Windows上安裝Python？</a></p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.youtube.com/watch?v=yivyNCtVVDk&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">如何在MacOS上安裝Python？</a></p><p class="paragraph" style="text-align:left;">如果你不想看視頻，可以直接從官方安裝<a class="link" href="https://www.python.org/downloads/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">Python</a>網站。</p><h3 class="heading" style="text-align:left;">安裝庫</h3><p class="paragraph" style="text-align:left;">現在，讓我們在資料夾中安裝該專案所需的庫。</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://pypi.org/project/beautifulsoup4/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">Beautiful Soup</a>— 用於解析從網站擷取的 HTML 的第三方函式庫。</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://pypi.org/project/httpx/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">HTTPX</a>— 用於 Python 的功能齊全的 HTTP 用戶端，用於從網站提取資料。</p><p class="paragraph" style="text-align:left;">如果您不想閱讀他們的文檔，請透過執行以下命令來安裝這兩個庫。</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">pip install httpx
pip install beautifulsoup4</pre></div><h3 class="heading" style="text-align:left;">流程</h3><p class="paragraph" style="text-align:left;">這樣，我們就完成了用於抓取 Google 的 Python 專案的設定。讓我們先導入我們將在本教程中進一步使用的庫。 </p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">import httpx
import asyncio
from bs4 import BeautifulSoup</pre></div><p class="paragraph" style="text-align:left;">然後，我們將定義一個非同步函數，該函數將從中抓取有機<a class="link" href="https://www.google.com/search?q=python+tutorial&gl=us&hl=en&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">數據網頁</a>。 </p><p class="paragraph" style="text-align:left;">定義函數後，我們將 headers 變數初始化為使用者代理，以使我們的抓取機器人模仿有機用戶。</p><p class="paragraph" style="text-align:left;">用戶代理程式是一個請求標頭，用於標識請求軟體的裝置。 </p><p class="paragraph" style="text-align:left;">如果您想了解有關標頭的更多信息，請參閱本指南：<a class="link" href="https://serpdog.io/blog/web-scraping-with-python/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">使用 Python 進行網頁抓取</a></p><p class="paragraph" style="text-align:left;">然後，我們使用非同步上下文管理器來建立 HTTP 用戶端。最後，我們使用該用戶端使用關鍵字對目標 URL 發出帶有指定標頭的 HTTP GET 請求，await以等待伺服器的回應。</p><p class="paragraph" style="text-align:left;">現在，在上下文管理器中，我們將建立一個 BeautifulSoup 物件來解析和瀏覽 HTML。</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">async with httpx.AsyncClient() as client:
    response = await client.get("https://www.google.com/search?q=python+tutorial&gl=us&hl=en", headers=headers)
    soup = BeautifulSoup(response.content, "html.parser")</pre></div><p class="paragraph" style="text-align:left;">建立 Beautiful Soup 物件後，我們將從 HTML 中找到所需元素的標籤。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/cba9fa8c-cc60-4c9b-a4dd-16df947789ed/scrape-google-search-results-using-python-2-1536x743.png?t=1714610083"/></div><p class="paragraph" style="text-align:left;">如果您檢查網頁，您會發現每個自然結果都位於divclass 容器下g。 </p><p class="paragraph" style="text-align:left;">因此，我們將使用該類別循環遍歷每個div標籤g，以從 HTML 中獲取所需的資訊。</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">organic_results = []
 
for el in soup.select(".g"):</pre></div><p class="paragraph" style="text-align:left;">然後，我們將找到標題、描述和連結的標籤。</p><p class="paragraph" style="text-align:left;">如果你進一步檢查 HTML，或看一下上面的圖片，你會發現標題的標籤是h3，連結的標籤是 .yuRUbf &gt; a，描述的標籤是 .VwiC3b。</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">        organic_results = []
        i = 0
 
        for el in soup.select(".g"):
            organic_results.append({
                "title": el.select_one("h3").text,
                "link": el.select_one(".yuRUbf &gt; a")["href"],
                "description": el.select_one(".VwiC3b").text,
                "rank": i+1
            })
 
            i+=1   
 
        print(organic_results)
 
 
asyncio.run(get_organic_data())
</pre></div><p class="paragraph" style="text-align:left;">在您的終端機中執行此程式碼。您將能夠從 Google 獲取所需的資料。</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">[
  {
    "title": "The Python Tutorial \u2014 Python 3.11.3 documentation",
    "link": "https://docs.python.org/3/tutorial/",
    "description": "This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. It helps to have a Python interpreter\u00a0...",
    "rank": 1
  },
  {
    "title": "Python Tutorial",
    "link": "https://www.w3schools.com/python/",
    "description": "Learn by examples! This tutorial supplements all explanations with clarifying examples. See All Python Examples. Python Quiz. Test your Python skills with a\u00a0...",
    "rank": 2
  },
  .....</pre></div><p class="paragraph" style="text-align:left;">恭喜！</p><p class="paragraph" style="text-align:left;">您已經成功製作了一個 Python 腳本來抓取 Google 搜尋結果。</p><p class="paragraph" style="text-align:left;">但這種方法仍然不能用於大規模地從 Google 抓取數據，因為這可能會導致您的 IP 被 Google 永久封鎖。相反，你可以嘗試這個<a class="link" href="https://serpdog.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">Google抓取API</a>從谷歌抓取資料而不被阻止。</p><h2 class="heading" style="text-align:left;">使用 Google Search API 抓取搜尋結果</h2><p class="paragraph" style="text-align:left;">Serpdog 提供了一個簡單且簡化的解決方案，透過其強大的功能來抓取 Google 搜尋結果<a class="link" href="https://serpdog.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">搜尋引擎結果頁面 API</a>，它還解決了處理代理和驗證碼的問題，以實現順利的抓取過程。除了有機結果之外，它還以整個行業最實惠的價格提供大量額外數據。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/3a5dbf47-8188-424d-8eba-849853c69241/web-scraping-google-search-results-with-php-4-1024x491.png?t=1714610085"/></div><p class="paragraph" style="text-align:left;">Serpdog – Google 搜尋 API</p><p class="paragraph" style="text-align:left;">註冊後您還將獲得 1000 個免費 API 積分。</p><p class="paragraph" style="text-align:left;">在我們的網站上註冊後，您將獲得一個 API 金鑰。在下面的程式碼中複製您的 API 金鑰，您將能夠輕鬆地使用 Python 快速抓取 Google 搜尋結果。</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">import requests
payload = {'api_key': 'APIKEY', 'q':'python+tutorial' , 'gl':'us'}
resp = requests.get('https://api.serpdog.io/search', params=payload)
print (resp.text)</pre></div><h2 class="heading" style="text-align:left;">結論：</h2><p class="paragraph" style="text-align:left;">總的來說，Python 是一種優秀的語言，提供與網頁抓取相關的各種功能。然而，使用 Python 時存在某些限制，例如抓取 Google 時的回應速度較慢、缺乏對多執行緒的支持，以及由於大量請求而導致您的 IP 被 Google 封鎖的風險。</p><p class="paragraph" style="text-align:left;">建議在與 Google 打交道時實施道德策略。或者，開發人員可以集成 Google抓取API 進入他們的軟體以避免阻塞。</p><p class="paragraph" style="text-align:left;">在本教程中，我們學習了使用 Python 抓取 Google 搜尋結果。隨意地<a class="link" href="https://api.whatsapp.com/send?phone=85290901283&text=William+Digital+Marketing+%E6%8F%90%E4%BE%9B%E7%87%9F%E9%8A%B7%E6%96%B9%E6%B3%95%EF%BC%8C%E5%B9%AB%E5%8A%A9%E6%82%A8%E5%80%91%E7%B6%B2%E7%B5%A1%E7%94%9F%E6%84%8F%E5%A2%9E%E9%95%B7%EF%BC%8C%E9%9C%80%E8%A6%81%E4%B8%80%E5%B0%8D%E4%B8%80%E6%9C%83%E9%9D%A2%EF%BC%8C%E8%A8%98%E5%BE%97%E9%80%9A%E9%81%8E+Whatsapp+%E8%81%AF%E7%B5%A1%E6%88%91%E5%80%91%E3%80%82&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">給我發短信</a>您需要澄清的任何事情。關注我推特。謝謝閱讀！</p><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.beehiiv.com/?utm_campaign=538ca5c5-a8c7-451c-b0e5-49b7ea4a5198&utm_medium=post_rss&utm_source=william" target="_blank" rel="noopener noreferrer nofollow">Powered by beehiiv</a></p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=8382a198-600b-4d3f-b924-74ec9980d134&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>使用 Python 抓取 Google 搜尋結果 (2024)</title>
  <description>重點放在 Google 資料抓取</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/f1d85154-3262-4650-9b4a-a0d769fefefb/scraping-google-search-results-using-python.png" length="101379" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/scrape-google-search-results-with-python</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/scrape-google-search-results-with-python</guid>
  <pubDate>Mon, 22 Jan 2024 16:01:00 +0000</pubDate>
  <atom:published>2024-01-22T16:01:00Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Ai]]></category>
    <category><![CDATA[Program Coding]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:left;" id="python-google-2024"><b>使用 Python 抓取 Google 搜尋結果 ( 2024)</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://serpdog.io/wp-content/uploads/2023/06/scraping-google-search-results-using-python.png"/></div><p class="paragraph" style="text-align:left;">Python程式語言由Guido van Rossum於1991年開發，主要強調程式碼的可讀性和清晰簡潔的語法。</p><p class="paragraph" style="text-align:left;">本教學將教我們<b>使用 Python 抓取 Google 搜尋結果</b>。Python 在以下領域獲得了廣泛的流行網頁抓取由於可讀性、可擴展性等優勢，它成為了一個社群。這使得它成為其他程式語言的絕佳替代品，也是網頁抓取任務的完美選擇。</p><p class="paragraph" style="text-align:left;">這篇部落格文章不僅將重點放在 Google 資料抓取，還將讓您清楚地了解為什麼 Python 是從 Google 提取資料的最佳選擇，以及從 Google 收集資訊的好處有哪些。</p><div class="image"><img alt="" class="image__image" style="" src="https://serpdog.io/blog/wp-content/uploads/2023/06/scraping-google-search-results-using-python-1024x576.png"/><div class="image__source"><span class="image__source_text"><p>使用 Python 抓取 Google 搜尋結果</p></span></div></div><p class="paragraph" style="text-align:left;">我們將使用<code>HTTPX</code>和<code>BS4</code>來抓取和解析原始 HTML 資料。 </p><p class="paragraph" style="text-align:left;">閱讀本文後，您將對使用 Python 抓取 Google 搜尋結果有<b>基本的了解。</b>您還可以利用這些知識來使用其他程式語言進行未來的網頁抓取專案。</p><h2 class="heading" style="text-align:left;" id="python-google"><b>為什麼要用 Python 來抓取 Google 資料？</b></h2><p class="paragraph" style="text-align:left;">Python 是一種健全而強大的語言，非常重視其程式碼的可讀性和清晰度。這使得初學者能夠快速輕鬆地學習和實現抓取腳本。它還擁有一個龐大且活躍的開發人員社區，如果您的程式碼出現任何問題，他們可以為您提供幫助。</p><p class="paragraph" style="text-align:left;">使用 Python 的另一個優點是，它提供了專門為從 Web 抓取資料而設計的各種框架和程式庫，包括 Scrapy、BeautifulSoup、Playwright 和 Selenium。</p><p class="paragraph" style="text-align:left;">總的來說，Python 提供了許多優勢，例如高效能、可擴展性和各種其他抓取資源。這使得它不僅成為從 Google 提取資料的絕佳選擇，而且也適用於其他網頁抓取任務。</p><h2 class="heading" style="text-align:left;" id="python-google"><b>使用 Python 抓取 Google 搜尋結果</b></h2><p class="paragraph" style="text-align:left;">在這篇文章中，我們將建立一個基本的 Python 腳本來抓取前十個 Google 搜尋結果，包括它們的標題、描述和連結。</p><h3 class="heading" style="text-align:left;"><b>設定</b></h3><p class="paragraph" style="text-align:left;">對於那些尚未在其設備上安裝 Python 的用戶，請考慮以下影片：</p><ol start="1"><li><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.youtube.com/watch?v=yivyNCtVVDk&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">如何在Windows上安裝Python？</a></p></li><li><p class="paragraph" style="text-align:left;"><a class="link" href="https://www.youtube.com/watch?v=yivyNCtVVDk&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">如何在MacOS上安裝Python？</a></p></li></ol><p class="paragraph" style="text-align:left;">如果你不想看視頻，可以直接從官方安裝<a class="link" href="https://www.python.org/downloads/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">Python</a>網站。</p><h3 class="heading" style="text-align:left;"><b>安裝庫</b></h3><p class="paragraph" style="text-align:left;">現在，讓我們在資料夾中安裝該專案所需的庫。</p><ol start="1"><li><p class="paragraph" style="text-align:left;"><b><a class="link" href="https://pypi.org/project/beautifulsoup4/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">Beautiful Soup</a></b>— 用於解析從網站擷取的 HTML 的第三方函式庫。</p></li><li><p class="paragraph" style="text-align:left;"><b><a class="link" href="https://pypi.org/project/httpx/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">HTTPX</a></b>— 用於 Python 的功能齊全的 HTTP 用戶端，用於從網站提取資料。</p></li></ol><p class="paragraph" style="text-align:left;">如果您不想閱讀他們的文檔，請透過執行以下命令來安裝這兩個庫。</p><div class="codeblock"><pre><code>pip install httpx
pip install beautifulsoup4</code></pre></div><h3 class="heading" style="text-align:left;"><b>流程</b></h3><p class="paragraph" style="text-align:left;">這樣，我們就完成了用於抓取 Google 的 Python 專案的設定。讓我們先導入我們將在本教程中進一步使用的庫。 </p><div class="codeblock"><pre><code>import httpx
import asyncio
from bs4 import BeautifulSoup</code></pre></div><p class="paragraph" style="text-align:left;">然後，我們將定義一個非同步函數，該函數將從中抓取有機<a class="link" href="https://www.google.com/search?q=python+tutorial&gl=us&hl=en&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">數據網頁</a>。 </p><p class="paragraph" style="text-align:left;">定義函數後，我們將 headers 變數初始化為使用者代理，以使我們的抓取機器人模仿有機用戶。</p><p class="paragraph" style="text-align:left;"><b>用戶代理程式</b>是一個請求標頭，用於標識請求軟體的裝置。 </p><p class="paragraph" style="text-align:left;">如果您想了解有關標頭的更多信息，請參閱本指南：<a class="link" href="https://serpdog.io/blog/web-scraping-with-python/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">使用 Python 進行網頁抓取</a></p><p class="paragraph" style="text-align:left;">然後，我們使用非同步上下文管理器來建立 HTTP 用戶端。最後，我們使用該用戶端使用關鍵字對目標 URL 發出帶有指定標頭的 HTTP GET 請求，<code>await</code>以等待伺服器的回應。</p><p class="paragraph" style="text-align:left;">現在，在上下文管理器中，我們將建立一個 BeautifulSoup 物件來解析和瀏覽 HTML。</p><div class="codeblock"><pre><code>async with httpx.AsyncClient() as client:
    response = await client.get(&quot;https://www.google.com/search?q=python+tutorial&amp;gl=us&amp;hl=en&quot;, headers=headers)
    soup = BeautifulSoup(response.content, &quot;html.parser&quot;)</code></pre></div><p class="paragraph" style="text-align:left;"><span style="color:rgb(110, 114, 125);font-family:Circular Std;font-size:17px;">建立 Beautiful Soup 物件後，我們將從 HTML 中找到所需元素的標籤。</span></p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/af43b498-b88a-44e0-b79f-85c3ea4b3852/scrape-google-search-results-using-python-2-1536x743.png?t=1705928933"/></div><p class="paragraph" style="text-align:left;">如果您檢查網頁，您會發現每個自然結果都位於<code>div</code>class 容器下<code>g</code>。 </p><p class="paragraph" style="text-align:left;">因此，我們將使用該類別循環遍歷每個<code>div</code>標籤<code>g</code>，以從 HTML 中獲取所需的資訊。</p><div class="codeblock"><pre><code>organic_results = []
 
for el in soup.select(&quot;.g&quot;):</code></pre></div><p class="paragraph" style="text-align:left;"><span style="color:rgb(110, 114, 125);font-family:Circular Std;font-size:17px;">然後，我們將找到標題、描述和連結的標籤。</span></p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9cfdee6f-b2de-4c94-b27c-32246bc22c76/scrape-google-search-results-using-python-3-1536x733.png?t=1705929002"/></div><p class="paragraph" style="text-align:left;">如果你進一步檢查 HTML，或看一下上面的圖片，你會發現標題的標籤是<code>h3</code>，連結的標籤是 <code>.yuRUbf &gt; a</code>，描述的標籤是 <code>.VwiC3b</code>。</p><div class="codeblock"><pre><code>        organic_results = []
        i = 0
 
        for el in soup.select(&quot;.g&quot;):
            organic_results.append(&#123;
                &quot;title&quot;: el.select_one(&quot;h3&quot;).text,
                &quot;link&quot;: el.select_one(&quot;.yuRUbf &gt; a&quot;)[&quot;href&quot;],
                &quot;description&quot;: el.select_one(&quot;.VwiC3b&quot;).text,
                &quot;rank&quot;: i+1
            &#125;)
 
            i+=1   
 
        print(organic_results)
 
 
asyncio.run(get_organic_data())
</code></pre></div><p class="paragraph" style="text-align:left;">在您的終端機中執行此程式碼。您將能夠從 Google 獲取所需的資料。</p><div class="codeblock"><pre><code>[
  &#123;
    &quot;title&quot;: &quot;The Python Tutorial \u2014 Python 3.11.3 documentation&quot;,
    &quot;link&quot;: &quot;https://docs.python.org/3/tutorial/&quot;,
    &quot;description&quot;: &quot;This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. It helps to have a Python interpreter\u00a0...&quot;,
    &quot;rank&quot;: 1
  &#125;,
  &#123;
    &quot;title&quot;: &quot;Python Tutorial&quot;,
    &quot;link&quot;: &quot;https://www.w3schools.com/python/&quot;,
    &quot;description&quot;: &quot;Learn by examples! This tutorial supplements all explanations with clarifying examples. See All Python Examples. Python Quiz. Test your Python skills with a\u00a0...&quot;,
    &quot;rank&quot;: 2
  &#125;,
  .....</code></pre></div><p class="paragraph" style="text-align:left;">恭喜！</p><p class="paragraph" style="text-align:left;">您已經成功製作了一個 Python 腳本來抓取 Google 搜尋結果。</p><p class="paragraph" style="text-align:left;">但這種方法仍然不能用於大規模地從 Google 抓取數據，因為這可能會導致您的 IP 被 Google 永久封鎖。相反，你可以嘗試這個<a class="link" href="https://serpdog.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">Google抓取API</a>從谷歌抓取資料而不被阻止。</p><h2 class="heading" style="text-align:left;" id="google-search-api"><b>使用 Google Search API 抓取搜尋結果</b></h2><p class="paragraph" style="text-align:left;">Serpdog 提供了一個簡單且簡化的解決方案，透過其強大的功能來抓取 Google 搜尋結果<a class="link" href="https://serpdog.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">搜尋引擎結果頁面 API</a>，它還解決了處理代理和驗證碼的問題，以實現順利的抓取過程。除了有機結果之外，它還以整個行業最實惠的價格提供大量額外數據。</p><p class="paragraph" style="text-align:left;"></p><div class="image"><img alt="" class="image__image" style="" src="https://serpdog.io/wp-content/uploads/2023/03/web-scraping-google-search-results-with-php-4-1024x491.png"/><div class="image__source"><span class="image__source_text"><p>Serpdog – Google 搜尋 API</p></span></div></div><p class="paragraph" style="text-align:left;">註冊後您還將獲得 1000 個免費 API 積分。</p><p class="paragraph" style="text-align:left;">在我們的網站上註冊後，您將獲得一個 API 金鑰。在下面的程式碼中複製您的 API 金鑰，您將能夠輕鬆地使用 Python 快速抓取 Google 搜尋結果。</p><div class="codeblock"><pre><code>import requests
payload = &#123;&#39;api_key&#39;: &#39;APIKEY&#39;, &#39;q&#39;:&#39;python+tutorial&#39; , &#39;gl&#39;:&#39;us&#39;&#125;
resp = requests.get(&#39;https://api.serpdog.io/search&#39;, params=payload)
print (resp.text)</code></pre></div><h2 class="heading" style="text-align:left;"><b>結論：</b></h2><p class="paragraph" style="text-align:left;">總的來說，Python 是一種優秀的語言，提供與網頁抓取相關的各種功能。然而，使用 Python 時存在某些限制，例如抓取 Google 時的回應速度較慢、缺乏對多執行緒的支持，以及由於大量請求而導致您的 IP 被 Google 封鎖的風險。</p><p class="paragraph" style="text-align:left;">建議在與 Google 打交道時實施道德策略。或者，開發人員可以集成 Google抓取API 進入他們的軟體以避免阻塞。</p><p class="paragraph" style="text-align:left;">在本教程中，我們學習了使用 Python 抓取 Google 搜尋結果。隨意地<a class="link" href="https://api.whatsapp.com/send?phone=85290901283&text=William+Digital+Marketing+%E6%8F%90%E4%BE%9B%E7%87%9F%E9%8A%B7%E6%96%B9%E6%B3%95%EF%BC%8C%E5%B9%AB%E5%8A%A9%E6%82%A8%E5%80%91%E7%B6%B2%E7%B5%A1%E7%94%9F%E6%84%8F%E5%A2%9E%E9%95%B7%EF%BC%8C%E9%9C%80%E8%A6%81%E4%B8%80%E5%B0%8D%E4%B8%80%E6%9C%83%E9%9D%A2%EF%BC%8C%E8%A8%98%E5%BE%97%E9%80%9A%E9%81%8E+Whatsapp+%E8%81%AF%E7%B5%A1%E6%88%91%E5%80%91%E3%80%82&utm_source=beehiiv&utm_medium=William&utm_campaign=python-google-2024" target="_blank" rel="noopener noreferrer nofollow">給我發短信</a>您需要澄清的任何事情。關注我推特。謝謝閱讀！</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=538ca5c5-a8c7-451c-b0e5-49b7ea4a5198&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>如何在 5 分鐘內使用 WordPress 建立人工智慧工具!</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2023/11/kittl-affiliatewilliam-14-150x150.jpg&quot; class=&quot;attachment-thumbnai</description>
  <link>https://affiliatewilliam.beehiiv.com/p/how-to-create-ai-tools-with-wordpress-in-5-minutes</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/how-to-create-ai-tools-with-wordpress-in-5-minutes</guid>
  <pubDate>Thu, 11 Jan 2024 13:49:30 +0000</pubDate>
  <atom:published>2024-01-11T13:49:30Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/3cf8d911-2e69-433a-9278-d7c6c6acc41a/kittl-affiliatewilliam-14-150x150.jpg?t=1714610085"/></div><p class="paragraph" style="text-align:left;"><b>Create. A. I.</b>助手</p><p class="paragraph" style="text-align:left;">利用 A.I 人工智能工具大大改進您的營業額.</p><div class="button" style="text-align:center;"><a target="_blank" rel="noopener nofollow noreferrer" class="button__link" style="" href="https://direct.me/affiliatewilliam?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress"><span class="button__text" style=""> 歡迎查詢 </span></a></div><p class="paragraph" style="text-align:left;">Online Tools</p><p class="paragraph" style="text-align:left;">工具結構</p><p class="paragraph" style="text-align:left;">步驟</p><h2 class="heading" style="text-align:left;">為什麼要創建線上工具？</h2><h3 class="heading" style="text-align:left;"><b>1.獲得更多流量：</b></h3><ul><li><p class="paragraph" style="text-align:left;"><b>參與度：</b>線上工具，尤其是那些由人工智慧驅動的工具，可以吸引和吸引用戶，使他們在您的網站上花費更多時間。</p></li><li><p class="paragraph" style="text-align:left;"><b>SEO 的好處：</b>獨特的互動式內容可以提高網站的搜尋引擎排名，帶來更多的自然流量。</p></li><li><p class="paragraph" style="text-align:left;"><b>可分享性：</b>如果您的工具提供價值，使用者就更有可能在社群媒體上分享它，從而進一步擴大您的影響力。</p></li></ul><p class="paragraph" style="text-align:left;">建立PromoterKit 和FreeeAIKit 等線上工具，幫助我在相當長的時間內接觸到全球數百萬用戶。在不到一年的時間裡，我現在每個月持續獲得 10 萬用戶！<b>特別是如果您利用快速獲勝</b>關鍵字的力量。</p><h3 class="heading" style="text-align:left;"><b>2. 鉛磁鐵：</b></h3><ul><li><p class="paragraph" style="text-align:left;"><b>擷取資訊：</b>需要使用者輸入或註冊的工具可以幫助您擷取有價值的訊息，例如電子郵件地址。</p></li><li><p class="paragraph" style="text-align:left;"><b>細分：</b>透過了解訪客如何使用您的工具，您可以細分受眾以進行更個人化的行銷。</p></li><li><p class="paragraph" style="text-align:left;"><b>建立信任：</b>免費或試用提供有價值的工具可以培養信任和忠誠度，將訪客轉化為長期客戶或訂閱者。</p></li></ul><h3 class="heading" style="text-align:left;"><b>3. 貨幣化：</b></h3><ul><li><p class="paragraph" style="text-align:left;"><b>訂閱模式：</b>您可以限制對高級功能的訪問，為不同的用戶需求提供分層訂閱模式。</p></li><li><p class="paragraph" style="text-align:left;"><b>廣告收入：</b>如果該工具吸引了大量用戶群，您可以透過有針對性的廣告獲利。</p></li><li><p class="paragraph" style="text-align:left;"><b>B2B 合作夥伴關係：</b>您的工具可能會吸引對白標解決方案或協作感興趣的商業客戶。</p></li></ul><h2 class="heading" style="text-align:left;">了解工具結構</h2><p class="paragraph" style="text-align:left;">在 WordPress 上建立 AI 工具涉及 3 個主要步驟。以下是如何建立此工具的詳細說明：</p><h3 class="heading" style="text-align:left;"><b>1. 建立 WordPress 頁面：</b></h3><p class="paragraph" style="text-align:left;">首先在託管 AI 工具的 WordPress 網站上建立一個新頁面。該頁面將是與該工具互動的使用者介面。</p><h3 class="heading" style="text-align:left;"><b>2.新增HTML程式碼：</b></h3><p class="paragraph" style="text-align:left;">新增一些 HTML 程式碼來建立工具頁面。這將是與 OpenAI API 通訊的起點。</p><h3 class="heading" style="text-align:left;"><b>3. 實現WordPress功能：</b></h3><p class="paragraph" style="text-align:left;">您將新增一個自訂 WordPress 函數，接收來自 HTML 表單的使用者輸入並將其傳送到 OpenAI 的 API。該功能可作為您的網站和 OpenAI 之間的橋樑，可讓兩者進行通訊。</p><h3 class="heading" style="text-align:left;"><b>4. 連接OpenAI API：</b></h3><p class="paragraph" style="text-align:left;">WordPress 功能將與 OpenAI 的 API 連接，根據使用者的提示產生文字。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/958ea8f8-003f-4997-b1a3-04492f75a809/Copy-of-Prompt-Engineering-Guide-720-_-300-px-3.png?t=1714610085"/></div><h2 class="heading" style="text-align:left;"><b>取得 OpenAI API 金鑰：</b></h2><p class="paragraph" style="text-align:left;">要使用 OpenAI 的任何模型，您必須先取得 API 存取金鑰。操作方法如下：</p><ul><li><p class="paragraph" style="text-align:left;">前往<a class="link" href="https://openai.com/api/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow">OpenAI 的 API 頁面</a>並點擊“註冊”按鈕。</p></li><li><p class="paragraph" style="text-align:left;">系統將提示您建立帳戶。驗證您的電子郵件以完成註冊程序。</p></li><li><p class="paragraph" style="text-align:left;">登入後，您可以在帳戶儀表板下找到您的 API 金鑰。</p></li></ul><p class="paragraph" style="text-align:left;">如需更深入的指導，您可以在此處查看我的有關 GPT-4 API 入門的<a class="link" href="https://learnwithhasan.com/gpt-4-api-guide/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow">完整</a><a class="link" href="https://learnwithhasan.com/gpt-4-api-guide/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow">指南</a>。</p><h2 class="heading" style="text-align:left;">第1步：新增API呼叫功能</h2><p class="paragraph" style="text-align:left;">在此步驟中，我們將新增 PHP 函數，使我們的工具能夠與 OpenAI API 進行通訊。為此，我們將使用WordPress 中的<b><a class="link" href="https://wordpress.org/plugins/insert-headers-and-footers/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow">WPCode</a></b>外掛程式。</p><h3 class="heading" style="text-align:left;"><b>什麼是 WPCode 插件？</b></h3><p class="paragraph" style="text-align:left;"><b>WPCode</b>是一個 WordPress 插件，它提供了一種乾淨簡單的方法來在您的網站上運行 PHP 程式碼片段。它消除了將自訂片段添加到主題functions.php文件的需要。</p><h3 class="heading" style="text-align:left;"><b>安裝並啟動程式碼片段插件</b></h3><ol start="1"><li><p class="paragraph" style="text-align:left;">從 WordPress 儀表板中，前往「外掛程式 &gt; 新增外掛」。</p></li><li><p class="paragraph" style="text-align:left;">在搜尋欄中輸入“ <b>WPCode</b> ”</p></li><li><p class="paragraph" style="text-align:left;">在搜尋結果中找到該插件，然後按一下“立即安裝”，然後按一下“啟動”。</p></li></ol><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/63ccba2e-b4aa-4d21-8573-cdadfcb930e3/Screenshot-2023-07-26-140703.png?t=1714610087"/></div><p class="paragraph" style="text-align:left;"><b>新增 OpenAI API 呼叫</b></p><p class="paragraph" style="text-align:left;">啟動外掛程式後，請依照下列步驟新增 API 呼叫：</p><ol start="1"><li><p class="paragraph" style="text-align:left;">從 WordPress 儀表板中，導覽至「<b>程式碼片段</b>&gt; 新增內容」。</p></li><li><p class="paragraph" style="text-align:left;">在「標題」欄位中，為新程式碼段命名，例如「OpenAI API 呼叫」。</p></li><li><p class="paragraph" style="text-align:left;">將代碼類型設定為<b>PHP</b></p></li><li><p class="paragraph" style="text-align:left;">在「代碼」文字方塊中，您將輸入 PHP 程式碼。下面是如何建構此程式碼的範例：</p></li></ol><p class="paragraph" style="text-align:left;">/</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">function openai_generate_text() {
    // Get the topic from the AJAX request
    $prompt = $_POST['prompt'];

    // OpenAI API URL and key
    $api_url = 'https://api.openai.com/v1/chat/completions';
    $api_key = 'sk-XXX';  // Replace with your actual OpenAI API key

    // Headers for the OpenAI API
    $headers = [
        'Content-Type' =&gt; 'application/json',
        'Authorization' =&gt; 'Bearer ' . $api_key
    ];

    // Body for the OpenAI API
    $body = [
        'model' =&gt; 'gpt-3.5-turbo',
        'messages' =&gt; [['role' =&gt; 'user', 'content' =&gt; $prompt]],
        'temperature' =&gt; 0.7
    ];

    // Args for the WordPress HTTP API
    $args = [
        'method' =&gt; 'POST',
        'headers' =&gt; $headers,
        'body' =&gt; json_encode($body),
        'timeout' =&gt; 120
    ];

    // Send the request
    $response = wp_remote_request($api_url, $args);

    // Handle the response
    if (is_wp_error($response)) {
        $error_message = $response-&gt;get_error_message();
        wp_send_json_error("Something went wrong: $error_message");
    } else {
        $body = wp_remote_retrieve_body($response);
        $data = json_decode($body, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            wp_send_json_error('Invalid JSON in API response');
        } elseif (!isset($data['choices'])) {
            wp_send_json_error('API request failed. Response: ' . $body);
        } else {
            wp_send_json_success($data);
        }
    }

    // Always die in functions echoing AJAX content
   wp_die();
}

add_action('wp_ajax_openai_generate_text', 'openai_generate_text');
add_action('wp_ajax_nopriv_openai_generate_text', 'openai_generate_text');</pre></div><p class="paragraph" style="text-align:left;">程式碼定義了一個名為 的 PHP 函數，<b>openai_generate_text</b>當使用操作向 WordPress 發出請求時，該函數將會被執行openai_generate_text。</p><p class="paragraph" style="text-align:left;">該函數與 OpenAI 的 API 進行通信，根據使用者提供的提示產生文字。</p><p class="paragraph" style="text-align:left;">此函數首先從 POST 請求中檢索使用者提供的提示：</p><p class="paragraph" style="text-align:left;"><i>$prompt = $_POST[‘提示’];</i></p><p class="paragraph" style="text-align:left;">程式碼的最後兩行將函數與<i><b>wp_ajax_openai_generate_text</b></i>和操作掛鉤，以便當向 WordPress 發出<i><b>wp_ajax_nopriv_openai_generate_text</b></i>包含該操作的請求時執行該函數。openai_generate_text</p><h3 class="heading" style="text-align:left;">發布程式碼片段</h3><p class="paragraph" style="text-align:left;">現在，請確保將此腳本設定為在任何地方運行並發布它。</p><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/a53601d7-00c8-43e6-9673-b18a71669ce2/Screenshot-2023-07-26-144249.png?t=1714610088"/></div><h2 class="heading" style="text-align:left;">步驟2：建立工具頁面</h2><p class="paragraph" style="text-align:left;">現在我們已經準備好了 API 函數，讓我們在 WordPress 網站上建立一個新頁面，在其中新增我們的 AI 工具。</p><p class="paragraph" style="text-align:left;">我們將使用<b>Elementor</b>（一種流行的 WordPress 頁面建立器）來建立頁面。</p><p class="paragraph" style="text-align:left;"> <b>注意：</b>您可以使用任何您想要的建構器。重要的是能夠為頁面添加<b>自訂 HTML 程式碼。</b></p><h3 class="heading" style="text-align:left;"><b>安裝並啟用 Elementor</b></h3><ol start="1"><li><p class="paragraph" style="text-align:left;">從 WordPress 儀表板中，前往「外掛程式 &gt; 新增外掛」。</p></li><li><p class="paragraph" style="text-align:left;">在搜尋欄中，輸入「<b>Elementor</b>」。</p></li><li><p class="paragraph" style="text-align:left;">在搜尋結果中找到該插件，然後按一下“立即安裝”，然後按一下“啟動”。</p></li></ol><h3 class="heading" style="text-align:left;"><b>使用 Elementor 建立新頁面</b></h3><ol start="1"><li><p class="paragraph" style="text-align:left;">從 WordPress 儀表板導覽至「頁面 &gt; 新增內容」。</p></li><li><p class="paragraph" style="text-align:left;">輸入頁面的標題，例如“AI Tool”。</p></li><li><p class="paragraph" style="text-align:left;">點擊“<b>使用 Elementor 編輯</b>”開始設計頁面。</p></li></ol><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/2a46f8df-c1c5-43d6-866e-aec5df4833c9/Screenshot-2023-07-26-145755-1024x366.png?t=1714610089"/></div><h3 class="heading" style="text-align:left;"><b>在 Elementor 中新增自訂 HTML</b></h3><p class="paragraph" style="text-align:left;">要在 Elementor 中新增自訂 HTML，您需要將 HTML 程式碼小工具拖曳到頁面中。按著這些次序：</p><ol start="1"><li><p class="paragraph" style="text-align:left;">在 Elementor 編輯器頁面上，您會在左側看到一個帶有幾個圖示的側邊欄。單擊看起來像網格或矩陣的那個。</p></li><li><p class="paragraph" style="text-align:left;">這將打開您可以使用的小部件清單。尋找“HTML”小工具</p></li></ol><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9de7ca06-afb4-4971-adf5-62b2a7870753/Screenshot-2023-07-26-145903.png?t=1714610089"/></div><p class="paragraph" style="text-align:left;">您可以在此處貼上 AI 工具的自訂 HTML 程式碼。在我們的例子中，它將包括輸入欄位、按鈕和輸出結果文字區域的程式碼。</p><p class="paragraph" style="text-align:left;">基本範例：</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">&lt;div&gt;
    &lt;input type="text" id="userInput" placeholder="Type something here..."&gt;
    &lt;button id="submitButton"&gt;Submit&lt;/button&gt;
    &lt;textarea id="resultArea"&gt;&lt;/textarea&gt;
&lt;/div&gt;</pre></div><p class="paragraph" style="text-align:left;">為了讓您更輕鬆，我創建了完整的 HTML、JS 和 CSS 程式碼，以便您可以直接複製並貼上。我們到了：</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">&lt;div id="text-generation-tool"&gt;
    &lt;input type="text" id="topic" placeholder="Your Topic..."&gt;
    &lt;button id="generate-button"&gt;Generate Story!&lt;/button&gt;
    &lt;div id="result-container" style="display: none;"&gt;
        &lt;div class="result-wrapper"&gt;
            &lt;div class="result-content"&gt;
                &lt;textarea id="result" readonly&gt;&lt;/textarea&gt;
            &lt;/div&gt;
            &lt;div class="copy-button-container"&gt;
                &lt;button id="copy-button"&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="loading" class="loader" style="display: none;"&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;style&gt;
    /* Basic styles for the text generation tool */
    #text-generation-tool {
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
        font-family: Arial, sans-serif;
    }

    #topic {
        width: 100%;
        padding: 15px;
        margin-bottom: 20px;
        font-size: 16px;
        border-radius: 5px;
        border: 1px solid #ddd;
    }

    #generate-button {
        display: block;
        width: 100%;
        padding: 15px;
        margin-bottom: 20px;
        font-size: 16px;
        border: none;
        border-radius: 5px;
        color: #fff;
        background-color: #3498db;
        cursor: pointer;
        transition: background-color 0.3s ease;
    }

    #generate-button:hover {
        background-color: #2980b9;
    }

    #result-container {
        display: none;
        margin-bottom: 20px;
    }

    .result-wrapper {
        position: relative;
        overflow: hidden;
    }

    .result-content {
        display: flex;
    }

    #result {
        flex: 1;
        height: 400px;
        padding: 15px;
        font-size: 16px;
        border-radius: 5px;
        border: 1px solid #ddd;
        background-color: #f9f9f9;
    }

    .copy-button-container {
        margin-top: 10px;
        text-align: right;
    }

    #copy-button {
        padding: 8px 12px;
        font-size: 14px;
        border: none;
        border-radius: 5px;
        color: #fff;
        background-color: #3498db;
        cursor: pointer;
        transition: background-color 0.3s ease;
    }

    #copy-button:hover {
        background-color: #2980b9;
    }

    /* CSS for the loader */
    .loader {
        display: block;
        margin: 50px auto;
        border: 16px solid #f3f3f3; /* Light grey */
        border-top: 16px solid #3498db; /* Blue */
        border-radius: 50%;
        width: 50px;
        height: 50px;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
&lt;/style&gt;</pre></div><div class="custom_html"></div><p class="paragraph" style="text-align:left;">順便一提！我用 ChatGPT 在大約 5 分鐘內產生了這段程式碼！</p><p class="paragraph" style="text-align:left;">請隨意使用此程式碼作為您想要建立的任何工具的基線。例如，如果您想要變更輸入欄位中的佔位符文本，請調整此行：</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">&lt;input type="text" id="topic" placeholder="Your Topic..."&gt;</pre></div><p class="paragraph" style="text-align:left;">但這還不是全部。您甚至可以將此代碼輸入 ChatGPT 並要求其為您進行修改。讓我們來看一個實際的例子：</p><p class="paragraph" style="text-align:left;"><i><b>提示：“將輸入框更新為下拉列表，我可以在其中選擇以下選項之一：（愛、幫助、友誼）”</b></i></p><p class="paragraph" style="text-align:left;">執行此提示後，ChatGPT 產生的內容如下：</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">&lt;div id="text-generation-tool"&gt;
    &lt;select id="topic"&gt;
        &lt;option value="" selected disabled&gt;Your Topic...&lt;/option&gt;
        &lt;option value="love"&gt;Love&lt;/option&gt;
        &lt;option value="help"&gt;Help&lt;/option&gt;
        &lt;option value="friendship"&gt;Friendship&lt;/option&gt;
    &lt;/select&gt;
    &lt;button id="generate-button"&gt;Generate Story!&lt;/button&gt;
    &lt;div id="result-container" style="display: none;"&gt;
        &lt;div class="result-wrapper"&gt;
            &lt;div class="result-content"&gt;
                &lt;textarea id="result" readonly&gt;&lt;/textarea&gt;
            &lt;/div&gt;
            &lt;div class="copy-button-container"&gt;
                &lt;button id="copy-button"&gt;Copy&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="loading" class="loader" style="display: none;"&gt;&lt;/div&gt;
&lt;/div&gt;</pre></div><p class="paragraph" style="text-align:left;">像 ChatGPT 這樣的人工智慧模型的可能性幾乎是無限的，這就是為什麼學習如何與這些模型互動是當今最受歡迎的技能之一，並且在未來也將繼續如此。</p><p class="paragraph" style="text-align:left;">這項技能通常被稱為“<b><a class="link" href="https://learnwithhasan.com/prompt-engineering-guide/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow">即時工程</a></b>”，是有效利用人工智慧的關鍵方面。如果您有興趣了解有關此主題的更多信息，我鼓勵您查看我的即時工程綜合課程，<a class="link" href="https://learnwithhasan.com/prompt-engineering-course/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow"><b>請點擊此處。</b></a></p><h3 class="heading" style="text-align:left;">儲存您的頁面！</h3><p class="paragraph" style="text-align:left;">貼上程式碼後，按一下“更新”以儲存變更。</p><p class="paragraph" style="text-align:left;">完美的！現在您已經為 AI 工具建立了一個頁面並新增了必要的 HTML 元素。下一步將涉及將此頁面連接到我們的 OpenAI API 函數。</p><h2 class="heading" style="text-align:left;">步驟3：將頁面與API函數連接</h2><p class="paragraph" style="text-align:left;">現在我們已經設定了 API 函數和工具頁面，是時候連接它們了。這就是<b>JavaScript</b> (JS) 程式碼的用武之地。</p><h3 class="heading" style="text-align:left;"><b>這段 JavaScript 程式碼的作用是什麼？</b></h3><p class="paragraph" style="text-align:left;">此 JS 程式碼在「生成故事！」上設定一個事件偵聽器 按鈕，以便當單擊該按鈕時，它會收集用戶選擇的主題並使用 AJAX 將其發送到我們的 OpenAI API 函數。</p><p class="paragraph" style="text-align:left;">生成故事時，它會顯示一個載入旋轉器。返回故事後，它會隱藏載入微調器並將其顯示在結果文字區域中。</p><p class="paragraph" style="text-align:left;">如果任何時候出現錯誤，它都會在結果文字區域中顯示錯誤訊息。</p><p class="paragraph" style="text-align:left;">該程式碼還在「複製」按鈕上設定了一個事件偵聽器，以便在單擊時將生成的故事複製到剪貼簿。</p><h3 class="heading" style="text-align:left;"><b>新增 JavaScript 程式碼</b></h3><p class="paragraph" style="text-align:left;">以下是您需要新增的 JavaScript 程式碼：</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;">&lt;script&gt;
    document.getElementById("generate-button").addEventListener("click", function(e){
        e.preventDefault();
        
        
        var generateButton = document.getElementById("generate-button");
        
        if (generateButton.disabled) {
            return; // Prevent multiple clicks while content is being generated
        }
        
        generateButton.disabled = true;
        
        
        
        var topic = document.getElementById('topic').value;
        var prompt = "Generate a 3 sentence story about " + topic;
        var loading = document.getElementById('loading');
        var result = document.getElementById('result');
        var resultC = document.getElementById('result-container');

        


        

        loading.style.display = 'block';
        result.style.display = 'none'; // hide result textarea
        resultC.style.display = 'none';
        

        var formData = new FormData();
        formData.append('action', 'openai_generate_text');
        formData.append('prompt', prompt);

        fetch('/wp-admin/admin-ajax.php', {
            method: 'POST',
            body: formData
        })
        .then(response =&gt; response.json())
        .then(data =&gt; {
            loading.style.display = 'none';
            if(data.success) {
                result.value = data.data.choices[0].message.content; 
                result.style.display = 'block'; // show result textarea
                resultC.style.display = 'block';
                generateButton.disabled = false;
            } else {
                result.value = 'An error occurred: ' + data.data;
                result.style.display = 'block'; // show result textarea
                resultC.style.display = 'block';
                generateButton.disabled = false;
            }
        })
        .catch(error =&gt; {
            loading.style.display = 'none';
            result.value = 'An error occurred: ' + error.message;
            result.style.display = 'block'; // show result textarea
            resultC.style.display = 'block';
            generateButton.disabled = false;
            
        });
    });
    
    var copyButton = document.getElementById('copy-button');
    copyButton.addEventListener('click', function() {
        var result = document.getElementById('result');
        result.select();
        document.execCommand('copy');
        alert('Copied to clipboard!');
    });
&lt;/script&gt;</pre></div><p class="paragraph" style="text-align:left;">這裡你應該關注的是提示：</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;"> var prompt = "Generate a 3 sentence story about " + topic;</pre></div><p class="paragraph" style="text-align:left;">就我而言，我只是使用了一個非常基本的提示來幫助您理解這個概念。</p><p class="paragraph" style="text-align:left;">根據您的情況，並根據您的 AI 工具邏輯，您將添加自訂提示；例如，假設我們正在建立一個網域產生器工具。您將使用以下提示：</p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;"><b>Generate a list of 10 domain name ideas for a website about [topic], and provide a brief explanation for each suggestion.</b></pre></div><p class="paragraph" style="text-align:left;">如果您想更專業，請讓我給您一個使用人工智慧產生網域的<a class="link" href="https://learnwithhasan.com/premium-prompts-library/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow"><b>高級秘密強力提示：</b></a></p><div class="custom_html"><pre style="word-wrap:break-word;white-space:pre-wrap;"><b>Please generate 10 original and creative domain names specifically tailored for the [niche] niche,
focusing on its main concepts and target audience.
Your response should prioritize domain names that effectively capture the attention of the [niche]
audience and represent its key themes. For each domain name, provide a brief explanation (1-2 sentences)
highlighting its relevance to the niche. Ensure that each domain name meets the following criteria:

1. Brand Relevance: Maintain a strong connection with the niche and its central concepts.
2. Memorable: Design the domain names to be captivating, easy to remember, and with familiar spellings.
3. Concise: Keep each domain name between 6-14 characters for ease of typing and recall.
4. Simplicity: Avoid using hyphens and numbers for a cleaner appearance.
5. Keyword Incorporation: Utilize relevant niche keywords for improved SEO, if possible.
6. Pronunciation: Ensure that each domain name is easily understandable when spoken or “radio-friendly.”
7. Domain Extensions: Prioritize .com, .net, .org, and .ai extensions when applicable.
8. Legality: Refrain from infringing on existing trademarks or brands.

Your response should exhibit flexibility
and creativity while maintaining a focused approach on the [niche] niche,
providing a solid foundation for building a brand within that market.

[niche]:</b></pre></div><p class="paragraph" style="text-align:left;">如果您有興趣訪問我的完整電源提示庫，<a class="link" href="https://learnwithhasan.com/premium-prompts-library/?utm_source=beehiiv&utm_medium=William&utm_campaign=5-wordpress" target="_blank" rel="noopener noreferrer nofollow">請在此處查看</a>。</p><p class="paragraph" style="text-align:left;">無論如何，我們的想法是將您的提示替換為您的目標，然後您就完成了！</p><h3 class="heading" style="text-align:left;">將此 JavaScript 程式碼新增至您的工具頁面：</h3><ol start="1"><li><p class="paragraph" style="text-align:left;">再次開啟工具頁面的 Elementor 編輯器。</p></li><li><p class="paragraph" style="text-align:left;">將“HTML”小工具拖放到您的頁面上，就像我們之前所做的那樣。</p></li><li><p class="paragraph" style="text-align:left;">將 JavaScript 程式碼貼到「HTML 程式碼」方塊中。</p></li><li><p class="paragraph" style="text-align:left;">點擊“更新”以儲存您的更改。</p></li></ol><p class="paragraph" style="text-align:left;"><b>或者您可以將程式碼貼到我們之前使用過的同一個 HTML 程式碼框中。</b></p><p class="paragraph" style="text-align:left;">就是這樣！您的工具頁面現在已連接到 OpenAI API 功能，使用者應該能夠根據他們選擇的主題使用該工具。</p><h2 class="heading" style="text-align:left;"><b>優化我們的工具</b></h2><p class="paragraph" style="text-align:left;">一旦我們的工具啟動並運行，這個過程就不會停止。是時候進行優化了。範圍包括從完善 UI（使用者介面）到添加驗證碼等安全措施。</p><p class="paragraph" style="text-align:left;">像 ChatGPT 這樣的現代人工智慧的迷人之處之一是它的多功能性和適應性。例如，您可以要求 ChatGPT 最佳化程式碼、變更使用者介面或修改該工具的任何其他方面。</p><p class="paragraph" style="text-align:left;">假設您想要更改工具的使用者介面。您可以簡單地將此請求提供給 ChatGPT，例如：</p><p class="paragraph" style="text-align:left;"><i>“嘿，你能幫我為我的工具設計一個更乾淨、更專業的介面嗎？”</i></p><p class="paragraph" style="text-align:left;">ChatGPT 將提供建議，甚至根據您的需求自訂一套全新的 HTML/CSS 程式碼。</p><p class="paragraph" style="text-align:left;">添加驗證碼等安全措施也可以是一項重大改進，因為它有助於保護您的工具免受機器人攻擊並確保真正的用戶互動。您可以在線找到大量外掛程式和資源來將驗證碼添加到您的 WordPress 網站。</p><p class="paragraph" style="text-align:left;">最後，請記住，根據用戶回饋持續優化和更新您的工具是使您的工具更加用戶友好和成功的關鍵。</p><h2 class="heading" style="text-align:left;">獎勵：將您的工具貨幣化！</h2><p class="paragraph" style="text-align:left;">請記住，WordPress 不僅允許您創建和共享內容；還允許您創建和共享內容。它還提供了將人工智慧工具轉變為收入來源的可能性。無論您開發的是單一工具還是一整套人工智慧解決方案，使用 WordPress 都有多種獲利途徑。這是詳細指南：</p><h3 class="heading" style="text-align:left;"><b>1. 會員模式：</b></h3><p class="paragraph" style="text-align:left;">您可以在網站上建立會員專區，提供對 AI 工具的獨佔存取權。Promembership、MemberPress 等外掛程式就是為此目的量身訂做的。</p><ul><li><p class="paragraph" style="text-align:left;"><b>ProMembership：</b>該插件非常適合創建分層會員資格，允許您根據訂閱計劃授予不同的訪問級別，從而為各種價位提供機會。</p></li><li><p class="paragraph" style="text-align:left;"><b>MemberPress：</b> MemberPress 以其使用者友善性而聞名，它允許您限制對特定頁面或整個內容類別的存取。您可以設定一次性付款或定期訂閱以進行存取。</p></li></ul><h3 class="heading" style="text-align:left;"><b>2. 廣告和聯盟行銷：</b></h3><p class="paragraph" style="text-align:left;">如果您不想直接向用戶收費，您可以透過廣告或聯盟行銷來獲利。與相關行業合作夥伴合作，或使用適合您的受眾的廣告網路。</p><h3 class="heading" style="text-align:left;"><b>3. 將工具建構為自由服務：</b></h3><p class="paragraph" style="text-align:left;">您可以作為自由工作者提供這項服務。</p><p class="paragraph" style="text-align:left;">您的 WordPress 網站可以託管這些工具並作為組合，展示使用者對您的服務的期望。潛在客戶可以與您的工具進行交互，獲得有關您的工作品質和功能的第一手經驗。您也可以考慮提供案例研究或推薦來進一步證明您的專業知識。</p><h3 class="heading" style="text-align:left;"><b>4. 使用 WordPress 建立 SaaS：</b></h3><p class="paragraph" style="text-align:left;">結合上述策略，您基本上可以使用 WordPress 建立一個軟體即服務 (SaaS) 平台。利用各種外掛程式創建無縫工作流程，整合支付網關，並為您的用戶提供專業、精緻的體驗。</p><p class="paragraph" style="text-align:left;">透過 WordPress 將人工智慧工具貨幣化不僅可行，而且回報豐厚。透過一系列適合不同工具和目標受眾的選項，您可以選擇最符合您的目標和使用者需求的方法。</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=808e8108-5f48-4038-85f7-29ced94e3b42&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>AI Sound</title>
  <description>&lt;img width=&quot;150&quot; height=&quot;150&quot; src=&quot;https://www.affiliatewilliam.com/wp-content/uploads/2023/11/She-believed-she-could-so-she-did-150x150.png&quot; class=&quot;attachment-</description>
  <link>https://affiliatewilliam.beehiiv.com/p/aisound</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/aisound</guid>
  <pubDate>Thu, 21 Dec 2023 05:31:10 +0000</pubDate>
  <atom:published>2023-12-21T05:31:10Z</atom:published>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/b239c739-a882-4917-b11f-4281137adf8e/She-believed-she-could-so-she-did-150x150.png?t=1714610088"/></div><p class="paragraph" style="text-align:left;">Ai 劉德華</p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=127912ab-b74e-416c-b9d1-a52d68abfc05&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>擁有策略性服務定位的藝術</title>
  <description>綜合型服務?代表只提供單一服務的 freelancer 不用玩了?</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/8dc0f2dc-ec92-497c-9038-f0b744803064/pexels-google-deepmind-18069083.jpg" length="494744" type="image/jpeg"/>
  <link>https://affiliatewilliam.beehiiv.com/p/the-art-of-strategic-service-positioning</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/the-art-of-strategic-service-positioning</guid>
  <pubDate>Tue, 19 Dec 2023 10:11:59 +0000</pubDate>
  <atom:published>2023-12-19T10:11:59Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Digital Marketing]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:center;">擁有策略性服務定位的藝術</h1><h2 class="heading" style="text-align:center;" id="freelancer">綜合型服務？代表只提供單一服務的 freelancer 不用玩了？</h2><div class="image"><img alt="" class="image__image" style="" src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/8dc0f2dc-ec92-497c-9038-f0b744803064/pexels-google-deepmind-18069083.jpg?t=1702980583"/><div class="image__source"><span class="image__source_text"><p>deepmind</p></span></div></div><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">綜合型服務有其優點，但缺點也是很明顯的：</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;"><b>那就是需要 freelancer 掌握至少兩種技能，或是愿意花時間去學習其他技能，以便能跟自己現有的技能做搭配。</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">不過，我相信還是有不少朋友只想專精在一個技能，自己也沒那個意願，或沒時間去學習其他技能。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">好消息是，</span><span style="font-size:16px;"><b>就算你只想提供單一服務，還是可以透過策略性地服務定位去提升自己的報價。</b></span></p><h1 class="heading" style="text-align:left;" id="roi"><span style="color:rgb(45, 55, 72);font-size:26px;"><b>服務定位：先來瞭解「便利性服務」 & 「ROI 服務」</b></span></h1><p class="paragraph" style="text-align:left;"><span style="font-size:16px;"><b>當談到如何收取高單價時，重點不在於你所提供的服務性質，而是你如何去定位自己的服務。</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">假設你是一位部落客，寫作能力超强，現在想要透過寫作這個技能去接案增加自己的收入。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">那如果你是在幫一個企業/商家去管理他們的部落格，定期幫他們產出文章的話，我相信你也知道這樣的服務很難開出很高的價格。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">就我之前當 SEO 文章寫手的經驗，最好的情況下，一篇 5000 字的原創文章也只能收 200 美金。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">重點是一篇好文章通常會需要寫手花很多時間去查資料再寫出來的，考慮到我們花費的時間成本，這樣的費用真的不多啦。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">再説了，SEO 文章也會需要一定的時間才能獲得排名，再加上現在市場上也推出了各種各樣的 AI 工具，這又會進一步降低多數企業/商家的感知價值（哭啊~~)</span></p><p class="paragraph" style="text-align:left;"></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">從另一個角度來看，幫一個企業/商家寫 SEO 文章，</span><span style="font-size:16px;"><b>你在賣的其實是一種「便利性服務」（Convenient Offer）。</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;"><b>簡單來説，就是幫企業/商家節省他們的時間</b></span><span style="font-size:16px;">，讓他們可以專注在更重要的工作上，而不是每天都花幾個小時在電腦前寫一堆無法馬上獲得排名的文章。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">其他常見的「便利性服務」還有：</span></p><ul><li><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">日常影片剪輯</span></p></li><li><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">短影片剪輯</span></p></li><li><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">WordPress 形象網站架設</span></p></li><li><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">社群貼文製作</span></p></li></ul><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">很明顯，</span><span style="font-size:16px;"><b>這些服務的最大問題就是，接案者真的特別難去跟客戶收超高單價的費用。</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">如果你很清楚自己現在的接案服務較傾向於「便利性服務」，最快的解決方案就是…</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;"><b>改變你的服務定位，將你的服務轉變成一個有利於爲客戶更快獲得可觀回報的「ROI 服務」（ROI Offer）。</b></span></p><h1 class="heading" style="text-align:left;" id="roi-offer"><span style="color:rgb(45, 55, 72);font-size:26px;"><b>怎麽利用 ROI Offer 的定位原理去提升服務的價值，好讓自己能收超高單價的費用</b></span></h1><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">現在假設你還是做一樣的東西好了，也就是寫作。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">但是，這次寫的内容不再是部落格文章，而是… ㅤ</span></p><ul><li><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">臉書廣告的文案</span></p></li><li><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">銷售頁的文案</span></p></li><li><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">銷售影片的脚本 ㅤ</span></p></li></ul><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">要知道，銷售文案 & 影片脚本寫的好，再搭配出色的銷售影片剪輯的話，這廣告投出去了是會帶給客戶超級可觀的 ROI 哦！</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">因此，比起一般的社群貼文還是部落格文章，這類的銷售型文案的價值明顯高出好幾倍。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">所以説，</span><span style="font-size:16px;"><b>如果你現在的接案事業的收入一直卡關，也許你只需要改變一下你的產品的定位還有包裝方式</b></span><span style="font-size:16px;">；</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">像是從普通的部落格文章（便利性服務）轉而提供廣告文案的行銷服務（ROI 服務），收入很大可能就會在一夜之間翻倍！</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">當然，</span><span style="font-size:16px;"><b>如果你願意的話，也可以嘗試跟其他技能做搭配，或是跟其他接案者合作。</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">例如，你負責撰寫廣告文案，他負責銷售影片的剪輯，這就會是一個定位很好的綜合型服務。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">你也能藉此跟客戶再進一步談分潤的長期合作方式，讓自己事業的現金流更穩定。</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;"><b>不過換個角度來看，其實 ROI 服務在很大程度上也能節省客戶的時間。</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">所以説如果你的服務能幫助客戶節省更多時間的同時，讓他們獲得可觀的回報，這樣的服務很明顯有非常高的價值。</span></p><h1 class="heading" style="text-align:left;"><span style="color:rgb(45, 55, 72);font-size:26px;"><b>結言</b></span></h1><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">前面説了那麽多，如果你是完全零經驗的新手，對網路行銷也沒什麽概念，説實話要做到這樣的成績還有一個相當重要的條件，那就是…</span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;"><b>你一定要對自己的服務有信心，相信自己的服務值得更高的報價！</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;"><b>如果你確實是花了很多年去磨練自己的技能，也深知自己的服務所能帶給客戶的回報會遠超于自己的收費，那你絕對是有資格去提高自己的報價的！</b></span></p><p class="paragraph" style="text-align:left;"><span style="font-size:16px;">這個部分唯一阻礙你的，也只有你的限制性思維了。</span></p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=56071e67-aaf2-46b2-807c-debd290b7e63&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

      <item>
  <title>6 個免費人工智能行銷工具</title>
  <description>人工智能正在迅速變化,為行銷人員提供了接觸、吸引和轉化客戶的新方法。</description>
      <enclosure url="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/046d41e3-23c0-4357-a58b-7e6ab362f372/rawpixel-aitoolscover.png" length="465762" type="image/png"/>
  <link>https://affiliatewilliam.beehiiv.com/p/6-free-ai-marketing-tools</link>
  <guid isPermaLink="true">https://affiliatewilliam.beehiiv.com/p/6-free-ai-marketing-tools</guid>
  <pubDate>Thu, 14 Dec 2023 01:04:08 +0000</pubDate>
  <atom:published>2023-12-14T01:04:08Z</atom:published>
    <dc:creator>William Affiliate</dc:creator>
    <category><![CDATA[Automation]]></category>
    <category><![CDATA[Ai]]></category>
    <category><![CDATA[Digital Marketing]]></category>
  <content:encoded><![CDATA[
    <div class='beehiiv'><style>
  .bh__table, .bh__table_header, .bh__table_cell { border: 1px solid #C0C0C0; }
  .bh__table_cell { padding: 5px; background-color: #FFFFFF; }
  .bh__table_cell p { color: #2D2D2D; font-family: 'Helvetica',Arial,sans-serif !important; overflow-wrap: break-word; }
  .bh__table_header { padding: 5px; background-color:#F1F1F1; }
  .bh__table_header p { color: #2A2A2A; font-family:'Trebuchet MS','Lucida Grande',Tahoma,sans-serif !important; overflow-wrap: break-word; }
</style><div class='beehiiv__body'><h1 class="heading" style="text-align:left;" id="6"><b>6 個免費人工智能行銷工具您必需嘗試</b></h1><p class="paragraph" style="text-align:left;">人工智能正在迅速變化，為行銷人員提供了接觸、吸引和轉化客戶的新方法。 AI 行銷工具是使用 AI 幫助您分析數據、自動執行任務和產生見解的平台。</p><p class="paragraph" style="text-align:left;">在本文中，我們將探討 6 個免費的行銷 AI 工具，它們可以幫助您取得出色的成果。讓我們開始吧。</p><h1 class="heading" style="text-align:start;" id="1-beacons"><b>1. beacons:</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*Qi_148mkTM3aQQNdNTmYnw.jpeg"/><div class="image__source"><span class="image__source_text"><p>beacons</p></span></div></div><p class="paragraph" style="text-align:start;">是一個一體化平台，可幫助您使用在簡歷、電子郵件行銷、銷售產品、分析、媒體工具包、定價計算器、AI 品牌推廣、受眾管理、發票、連結縮短器中建立自訂連結所需的所有工具、收入儀表板等等。</p><p class="paragraph" style="text-align:start;">beacons 是一個可以幫助您在一個地方增加追蹤者和收入的平台，而所有這些功能都是免費的。</p><p class="paragraph" style="text-align:start;">信標可以幫助您增加流量並銷售產品以最大限度地提高銷售。您還可以在幾分鐘內設定自動更新的媒體工具包，以贏得品牌交易並獲得贊助。</p><p class="paragraph" style="text-align:start;">而不是花錢購買多種工具。使用信標並免費完成這一切。</p><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://beacons.ai/affiliatewilliam?utm_source=beehiiv&utm_medium=William&utm_campaign=6" target="_blank" rel="noopener noreferrer nofollow">https://beacons.ai/</a></span></p><p class="paragraph" style="text-align:left;"></p><h1 class="heading" style="text-align:start;" id="2-uizard"><b>2. Uizard:</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*WkpvliPMCxvQ46IyrgaNrw.jpeg"/><div class="image__source"><span class="image__source_text"><p>Uizard</p></span></div></div><p class="paragraph" style="text-align:start;">Uizard 是一款快速、由人工智能驅動的 UI 設計工具。您可以輕鬆快速地設計行動應用程式、網頁應用程式、網站和桌面軟體。</p><p class="paragraph" style="text-align:start;">最棒的是，無需任何設計經驗。<br>您可以在幾秒鐘內輕鬆將螢幕截圖轉換為可編輯的設計。</p><p class="paragraph" style="text-align:start;">您可以使用 Uizard 掃描您的草圖並自動輕鬆地將其轉換為設計。</p><p class="paragraph" style="text-align:start;">您也可以上傳您的靈感照片，Uizard 將為您產生獨特的設計。</p><p class="paragraph" style="text-align:start;">Uizard 有很多預製的設計模板，您可以在幾秒鐘內拖放和調整它們。</p><p class="paragraph" style="text-align:start;">Uizard 包含免費使用的應用程式和 Web 模板，您可以調整它們以適合您自己的設計。</p><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://uizard.io/?utm_source=beehiiv&utm_medium=William&utm_campaign=6" target="_blank" rel="noopener noreferrer nofollow">https://uizard.io/</a></span></p><p class="paragraph" style="text-align:left;"></p><h1 class="heading" style="text-align:start;" id="3-algolia"><b>3. Algolia:</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*Ej4nUTBksuO25fnfuCLdGg.jpeg"/><div class="image__source"><span class="image__source_text"><p>Algolia</p></span></div></div><p class="paragraph" style="text-align:start;">是一個人工智能驅動的搜尋和發現平台，可幫助企業最大限度地提高搜尋速度。</p><p class="paragraph" style="text-align:start;">您可以比以前更快地訪問網站和應用程式上的正確內容或產品。</p><p class="paragraph" style="text-align:start;">Algolia 被 Coursera、Medium、Decathlon、Lacoste 以及更多品牌使用。</p><p class="paragraph" style="text-align:start;">Algolia 關鍵字搜尋具有不斷擴展的大規模功能，以實現您的目標。關鍵字搜尋功能非常快。</p><p class="paragraph" style="text-align:start;">Algolia 可以使用規則來偵測查詢中的關鍵字和保留字。</p><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://www.algolia.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=6" target="_blank" rel="noopener noreferrer nofollow">https://www.algolia.com/</a></span></p><p class="paragraph" style="text-align:left;"></p><h1 class="heading" style="text-align:start;" id="4-unbounce"><b>4. Unbounce:</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*S4dIYhmAuhsOgbivnW08Kg.jpeg"/><div class="image__source"><span class="image__source_text"><p>Unbounce</p></span></div></div><p class="paragraph" style="text-align:start;">是一款由人工智慧驅動的工具，可協助您建立具有智慧功能的登陸頁面。</p><p class="paragraph" style="text-align:start;">Unbounce 允許預先優化的登陸頁面以及為您編寫的副本。</p><p class="paragraph" style="text-align:start;">Unbounce 是一款出色且易於使用的登陸頁面軟體，用於創建高轉換率的登陸頁面。</p><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://unbounce.com/?utm_source=beehiiv&utm_medium=William&utm_campaign=6" target="_blank" rel="noopener noreferrer nofollow">https://unbounce.com/</a></span></p><p class="paragraph" style="text-align:left;"></p><h1 class="heading" style="text-align:start;" id="5-chatfuel"><b>5. Chatfuel:</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*izKycpD03kKrr9PZj4el6w.jpeg"/><div class="image__source"><span class="image__source_text"><p>Chatfuel</p></span></div></div><p class="paragraph" style="text-align:start;">是一款用於建立聊天機器人的人工智能工具，可幫助您增加銷售額、改善客戶支援並自動化追蹤者的對話。溝通。</p><p class="paragraph" style="text-align:start;">Chatfuel 使用 Open AI 的內建 GPT-4 向客戶介紹您的業務、回答他們的問題、推薦產品和服務等。</p><p class="paragraph" style="text-align:start;">它適用於最受歡迎的通訊工具和平台：Facebook Messenger、WhatsApp、Instagram 和您的網站。</p><p class="paragraph" style="text-align:start;">Chatfuel 受到 Netflix、Levi&#39;s、Nivea、Lego、Nissan 等眾多品牌的信賴。</p><p class="paragraph" style="text-align:start;">使用 Chatfuel 可以促進您的行銷和銷售並增加客戶溝通。</p><p class="paragraph" style="text-align:start;">Chatfuel 提供免費計劃，只要您的訂閱者數量不超過 50 人，您就可以使用所有功能。</p><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://chatfuel.com/ai?utm_source=beehiiv&utm_medium=William&utm_campaign=6" target="_blank" rel="noopener noreferrer nofollow">https://chatfuel.com/ai</a></span></p><p class="paragraph" style="text-align:left;"></p><h1 class="heading" style="text-align:start;" id="6-rytr"><b>6. Rytr:</b></h1><div class="image"><img alt="" class="image__image" style="" src="https://miro.medium.com/v2/resize:fit:700/1*3KSOF9pzocCHKxEAftRglQ.jpeg"/><div class="image__source"><span class="image__source_text"><p>rytr</p></span></div></div><p class="paragraph" style="text-align:start;">是一款人工智能寫作助手，可幫助您在幾秒鐘內創建內容。 Rytr 協助企業和行銷人員有效率且有效地創建內容。</p><p class="paragraph" style="text-align:start;">Rytr 使用 NLP 來理解用戶的查詢並創建部落格文章、社交媒體貼文等內容。</p><p class="paragraph" style="text-align:start;">當您開啟網站時，有多種可用的語言。您可以選擇任何語言以及語氣和內容類型，無論是部落格創意和大綱、電子郵件、求職信還是其他。然後為我點擊 Ryte。只需幾秒鐘，您就會獲得原創的高品質內容。</p><p class="paragraph" style="text-align:start;">Rytr 可以創建語法正確且沒有拼寫錯誤的高品質內容，從而節省時間。</p><p class="paragraph" style="text-align:start;"><span style="text-decoration:underline;"><a class="link" href="https://rytr.me/?utm_source=beehiiv&utm_medium=William&utm_campaign=6" target="_blank" rel="noopener noreferrer nofollow">https://rytr.me/</a></span></p><p class="paragraph" style="text-align:left;"></p><p class="paragraph" style="text-align:left;">結論:</p><p class="paragraph" style="text-align:left;"><span style="color:rgb(36, 36, 36);font-family:source-serif-pro, Georgia, Cambria, Times New Roman, Times, serif;font-size:20px;">無論您是需要在個人簡歷、電子郵件行銷、銷售產品、分析或訪問網站上正確的內容或產品，還是需要建立登陸頁面或設計行動應用程式、網路應用程式和網站，或建立聊天機器人或擁有寫作助理，都需要建立自訂連結這將幫助您創建內容，有一個人工智慧工具可以幫助您。</span></p></div><div class='beehiiv__footer'><br class='beehiiv__footer__break'><hr class='beehiiv__footer__line'><a target="_blank" class="beehiiv__footer_link" style="text-align: center;" href="https://www.beehiiv.com/?utm_campaign=7e8ec0ae-a2ac-450b-a4ca-80e58d54bb12&utm_medium=post_rss&utm_source=william">Powered by beehiiv</a></div></div>
  ]]></content:encoded>
</item>

  </channel>
</rss>
