<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Julian’s Playground - Medium]]></title>
        <description><![CDATA[coding, coding, coding - Medium]]></description>
        <link>https://medium.com/juliansplayground?source=rss----02346ba92d44---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Julian’s Playground - Medium</title>
            <link>https://medium.com/juliansplayground?source=rss----02346ba92d44---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:48:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/juliansplayground" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Translate eBooks Locally with Ollama + TranslateGemma]]></title>
            <link>https://medium.com/juliansplayground/translate-ebooks-locally-with-ollama-translategemma-fc657a8391b1?source=rss----02346ba92d44---4</link>
            <guid isPermaLink="false">https://medium.com/p/fc657a8391b1</guid>
            <dc:creator><![CDATA[Julian Shen]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 15:39:20 GMT</pubDate>
            <atom:updated>2026-08-31T15:39:21.372Z</atom:updated>
            <content:encoded><![CDATA[<p>So you’ve got an ebook… maybe it’s in English, maybe Japanese, maybe Chinese — and you just want it in <em>your</em> language. No cloud APIs, no fees, no weird privacy concerns.</p><p>Good news: you can do the whole thing locally with Calibre + a plugin + Ollama + a model called TranslateGemma.</p><p>It sounds fancy, but it’s actually pretty straightforward. Let’s walk through it.</p><h3>1) Install the Ebook Translator Plugin</h3><p>First, you need the plugin:</p><p>👉 <a href="https://github.com/bookfere/Ebook-Translator-Calibre-Plugin">https://github.com/bookfere/Ebook-Translator-Calibre-Plugin</a></p><h3>Quick steps</h3><ul><li>Open Calibre</li><li>Go to <strong>Preferences → Plugins</strong></li><li>Click <strong>“Load plugin from file”</strong></li><li>Select the downloaded .zip</li><li>Restart Calibre</li></ul><p>That’s it. You should now see <strong>Ebook Translator</strong> somewhere in your UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/110/1*x2ePXL0z2ZlJHOga5IRL9A.png" /></figure><h3>2) What’s TranslateGemma + Ollama?</h3><p>Let’s keep this simple.</p><ul><li>Ollama = runs AI models locally on your machine</li><li>TranslateGemma = a model that’s <em>really good at translation</em></li></ul><p>Together, they basically replace Google Translate… but fully local and customizable.</p><h3>Install &amp; run</h3><pre># install ollama<br>curl -fsSL https://ollama.com/install.sh | sh</pre><pre># download the model<br>ollama pull translategemma</pre><pre># try it<br>ollama run translategemma</pre><p>Ollama will expose a local API at:</p><pre>http://127.0.0.1:11434</pre><p>We’ll hook Calibre into this next.</p><h3>3) Set Up a Custom Engine (the important bit)</h3><p>Now we connect the plugin to Ollama.</p><h3>Where to go</h3><p>Inside Calibre:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*vMhHz5jnIfcCg3duyilPlg.png" /></figure><ul><li>Open <strong>Ebook Translator</strong></li><li>Go to <strong>Settings / Engines</strong></li><li>Add a <strong>Custom Engine</strong></li></ul><p>Then paste this config:</p><pre>{<br>    &quot;name&quot;: &quot;Ollama - TranslateGemma&quot;,<br>    &quot;languages&quot;: {<br>        &quot;source&quot;: {<br>            &quot;English&quot;: &quot;English (en)&quot;,<br>            &quot;Chinese&quot;: &quot;Chinese (zh-Hans)&quot;, <br>            &quot;Japanese&quot;: &quot;Japanese (ja)&quot;<br>        },<br>        &quot;target&quot;: { <br>            &quot;English&quot;: &quot;English (en)&quot;,<br>            &quot;Chinese&quot;: &quot;Chinese (zh-TW)&quot;,<br>            &quot;Spanish&quot;: &quot;Spanish (es)&quot;,<br>            &quot;Japanese&quot;: &quot;Japanese (ja)&quot;<br>        }<br>    },<br>    &quot;request&quot;: {<br>        &quot;url&quot;: &quot;http://127.0.0.1:11434/api/generate&quot;,<br>        &quot;method&quot;: &quot;POST&quot;,<br>        &quot;headers&quot;: {<br>            &quot;Content-Type&quot;: &quot;application/json&quot;<br>        },<br>        &quot;data&quot;: {<br>            &quot;model&quot;: &quot;translategemma&quot;,<br>            &quot;stream&quot;: false,<br>            &quot;prompt&quot;: &quot;You are a professional &lt;source&gt; to &lt;target&gt; translator. Your goal is to accurately convey the meaning and nuances of the original &lt;source&gt; text while adhering to &lt;target&gt; grammar, vocabulary, and cultural sensitivities. Produce only the &lt;target&gt; translation, without any additional explanations or commentary. Please translate the following &lt;source&gt; text into &lt;target&gt;:\n\n\n&lt;text&gt;&quot;<br>        }<br>    },<br>    &quot;response&quot;: &quot;response[&#39;response&#39;]&quot;<br>}</pre><h3>What’s going on here</h3><ul><li>Calibre sends text → Ollama API</li><li>Ollama runs <strong>TranslateGemma</strong></li><li>The model translates it</li><li>Calibre inserts the result back into your ebook</li></ul><p>No magic. Just clean plumbing.</p><h3>4) Pick a Book and Go</h3><p>Now the fun part.</p><h3>What to start with</h3><p>If this is your first try, don’t go straight into a 1000-page novel 😅</p><p>Try:</p><ul><li>Short novels</li><li>Light novels</li><li>Public domain books from Project Gutenberg</li><li>EPUB format (works best)</li></ul><h3>Translate it</h3><ul><li>Import your book into Calibre</li><li>Right-click → <strong>Translate Book</strong></li><li>Choose:</li><li>Engine: <em>Ollama — TranslateGemma</em></li><li>Source language</li><li>Target language</li><li>Hit go 🚀</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc657a8391b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/juliansplayground/translate-ebooks-locally-with-ollama-translategemma-fc657a8391b1">Translate eBooks Locally with Ollama + TranslateGemma</a> was originally published in <a href="https://medium.com/juliansplayground">Julian’s Playground</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crawling Dynamic Websites Using chromedp in Go]]></title>
            <link>https://medium.com/juliansplayground/crawling-dynamic-websites-using-chromedp-in-go-660feee9126a?source=rss----02346ba92d44---4</link>
            <guid isPermaLink="false">https://medium.com/p/660feee9126a</guid>
            <category><![CDATA[web-clawer]]></category>
            <category><![CDATA[chromedp]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[Julian Shen]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 18:47:28 GMT</pubDate>
            <atom:updated>2024-06-29T18:47:28.185Z</atom:updated>
            <content:encoded><![CDATA[<p>(This article is translated from <a href="https://blog.jln.co/Shi-Yong-Chromedp-Pa-Qu-Dong-Tai-Wang-Zhan-Zi-Liao/">https://blog.jln.co/Shi-Yong-Chromedp-Pa-Qu-Dong-Tai-Wang-Zhan-Zi-Liao/</a> with ChatGPT)</p><p>In modern web development, JavaScript-driven dynamic websites are becoming increasingly common, presenting challenges for traditional HTML parsing tools. Traditional methods are no longer suitable, as the content of web pages is generated only after executing JavaScript. Parsing such websites requires more front-end knowledge.</p><p>chromedp is a toolset written in Go language that performs headless browser automation via Chrome&#39;s DevTools protocol. This allows developers to programmatically control the Chrome browser, making it easy to crawl and parse dynamically generated content. This article will introduce how to use chromedp to create a simple web crawler.</p><p>chromedp mainly functions by communicating with the Chrome browser through the DevTools protocol. This enables developers to simulate user actions, such as navigating to web pages, clicking buttons, filling out forms, and extracting dynamically loaded content. These operations are performed in headless mode, meaning the browser interface is not visible, thus improving performance and resource efficiency. Through this approach, chromedp can handle scenarios that traditional HTML parsing tools cannot, especially when dealing with dynamically generated content.</p><h3>Simple Example Code</h3><p>Here is a simple example of using chromedp to crawl website data. This example demonstrates how to navigate to a website, select some elements, submit a form, and extract the required data:</p><pre>package main<br><br>import (<br>    &quot;context&quot;<br>    &quot;fmt&quot;<br>    &quot;log&quot;<br>    &quot;time&quot;<br><br>    &quot;github.com/chromedp/chromedp&quot;<br>)<br><br>func main() {<br>    // Create context<br>    ctx, cancel := chromedp.NewContext(context.Background())<br>    defer cancel()<br><br>    // Allocate browser<br>    ctx, cancel = chromedp.NewExecAllocator(ctx, chromedp.DefaultExecAllocatorOptions[:]...)<br>    defer cancel()<br><br>    // Create context with a 30-second timeout<br>    ctx, cancel = context.WithTimeout(ctx, 30*time.Second)<br>    defer cancel()<br><br>    // Execute tasks<br>    var res string<br>    err := chromedp.Run(ctx,<br>        chromedp.Navigate(&quot;https://example.com&quot;),<br>        chromedp.WaitVisible(`body`, chromedp.ByQuery),<br>        chromedp.SendKeys(`input[name=&quot;q&quot;]`, &quot;chromedp&quot;, chromedp.ByQuery),<br>        chromedp.Click(`input[type=&quot;submit&quot;]`, chromedp.ByQuery),<br>        chromedp.WaitVisible(`#result-stats`, chromedp.ByQuery),<br>        chromedp.Text(`#result-stats`, &amp;res, chromedp.ByQuery),<br>    )<br><br>    if err != nil {<br>        log.Fatal(err)<br>    }<br><br>    fmt.Println(&quot;Search Result Stats:&quot;, res)<br>}</pre><p>In this example, we create a chromedp task that navigates to example.com, waits for the page to load, enters &quot;chromedp&quot; in the search box, clicks the submit button, then waits for the search result stats element to be visible, and extracts that information. This is a basic example showing how to use chromedp for basic web interaction and data extraction. You can expand this example as needed to implement more complex crawlers.</p><p>Next, we will use a more practical case. The following example demonstrates how to use chromedp to crawl the schedule of the Chinese Professional Baseball League (CPBL), which is implemented using Vue.js.</p><h3>Analyze the document</h3><p>The URL of the CPBL schedule website is <a href="https://cpbl.com.tw/schedule">https://cpbl.com.tw/schedule</a>. First, we use “View Page Source” to inspect the web page and find that there is no schedule data in it. Additionally, we can find the following piece of code:</p><pre>var app = new Vue({<br>    el: &quot;#Center&quot;,<br>    mixins: [mixin],</pre><p>Another piece of code for obtaining schedule information is as follows:</p><pre>$.ajax({<br>    url: &#39;/schedule/getgamedatas&#39;,<br>    type: &#39;POST&#39;,<br>    data: filterData,<br>    headers: {<br>        RequestVerificationToken: &#39;PzmpuUOvS4z2zH_QhwgFQYTzVC82b0n2QH30wEOJ12kOWA6zeq0Yn7_6d2v_o-ZTWuNPe3HjrqsMqAHp9sL0F5KB4KM1:5jgubJ0tGDTK3cLm2JU7_bCw9JqLOG8j8yeNiWDhR4nnTACLXerDqmzB5chZv-iqY8m1ep6IirI3hAwRCPfNTU6jO_E1&#39;<br>    },<br>    success: function(result) {<br>        if (result.Success) {<br>            _this.gameDatas = JSON.parse(result.GameDatas);<br>            _this.getGames();<br>        }<br>    },<br>    error: function(res) {<br>        console.log(res);<br>    },<br>    complete: function () {<br>        $(&quot;body&quot;).unblock()<br>    }<br>});</pre><p>It is clear that this is a web page written in Vue.js. We could try hitting its API, but seeing that token string, it might have some protection in place, so using chromedp might be simpler.</p><p>How do we start parsing? Using ChatGPT might be a good method. Open Chrome’s developer tools, go to the Elements tab where the final rendered webpage is displayed, save it as a file, and ask ChatGPT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xzjdJwBtkvraW2sCCSLcIw.png" /><figcaption>Asking chatgpt to analyze the document (in Chinese)</figcaption></figure><p>You can also ask it to design the data structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N07lb1BwFiCwn4oyPwHrSQ.png" /><figcaption>Generate data structure with chatgpt (in Chinese)</figcaption></figure><p>This can only serve as an initial reference. You can later ask it to write the code for you. However, I tried it, and it only produces an example, not the correct result, but it’s useful as a foundation for modification.</p><p>First, define the requirements. We need to write a function that can input the year, month, and type of game to obtain the schedule information.</p><p>Based on this information, let’s write the first rough version to experiment with:</p><pre>type Game struct {<br>    No       int    `json:&quot;no&quot;`<br>    Year     int    `json:&quot;year&quot;`<br>    Month    int    `json:&quot;month&quot;`<br>    Day      int    `json:&quot;day&quot;`<br>    Home     string `json:&quot;home&quot;`<br>    Away     string `json:&quot;away&quot;`<br>    Ballpark string `json:&quot;ballpark&quot;`<br>}<br><br>func getGameNodes(nodes *[]*cdp.Node) chromedp.Action {<br>    return chromedp.ActionFunc(func(ctx context.Context) error {<br>        ctxWithTimeout, cancel := context.WithTimeout(ctx, 900*time.Millisecond)<br>        defer cancel()<br><br>        chromedp.Nodes(&quot;div.game&quot;, nodes).Do(ctxWithTimeout)<br>        for _, n := range *nodes {<br>            dom.RequestChildNodes(n.NodeID).WithDepth(6).Do(ctxWithTimeout)<br>        }<br><br>        return nil<br>    })<br>}<br><br>func selectMonth(month string) chromedp.QueryAction {<br>    return chromedp.SetValue(&quot;div.item.month select&quot;, month, chromedp.ByQueryAll)<br>}<br><br>func selectYear(year string) chromedp.QueryAction {<br>    return chromedp.SetValue(&quot;div.item.year select&quot;, year, chromedp.ByQueryAll)<br>}<br><br>func selectGameType(gtype string) chromedp.Action {<br>    return chromedp.SetValue(&quot;div.item.game_type select&quot;, gtype, chromedp.ByQueryAll)<br>}<br><br>func fetchGamesByMonth(ctx context.Context, year string, month string) ([]Game, error) {<br>    chromedp.Run(ctx, selectMonth(month),<br>        chromedp.WaitVisible(&quot;div.ScheduleGroup&quot;),<br>        chromedp.Sleep(800*time.Millisecond),<br>    )<br><br>    var nodes []*cdp.Node<br>    var mn string<br><br>    chromedp.Run(ctx,<br>        chromedp.Text(&quot;.date_selected .date&quot;, &amp;mn),<br>        getGameNodes(&amp;nodes),<br>    )<br><br>    var games []Game = make([]Game, len(nodes))<br>    for i, node := range nodes {<br>        games[i].No, _ = strconv.Atoi(strings.Trim(node.Children[0].Children[0].Children[0].Children[1].Children[0].NodeValue, &quot; &quot;))<br>        games[i].Ballpark = node.Children[0].Children[0].Children[0].Children[0].Children[0].NodeValue<br>        games[i].Year, _ = strconv.Atoi(year)<br>        monthInt, _ := strconv.Atoi(month)<br>        games[i].Month = monthInt + 1<br>        dataDate := node.Parent.Children[0].AttributeValue(&quot;data-date&quot;)<br>        day, _ := strconv.Atoi(dataDate)<br>        games[i].Day = day<br>        games[i].Away = node.Children[0].Children[0].Children[1].Children[0].Children[0].AttributeValue(&quot;title&quot;)<br>        games[i].Home = node.Children[0].Children[0].Children[1].Children[2].Children[0].AttributeValue(&quot;title&quot;)<br>    }<br><br>    return games, nil<br>}</pre><p>This version of the code is rough but usable, heavily relying on NodeValue and AttributeValue to fetch values. The problem with this code is that each chromedp call requires a call to Chrome, achieved through the Chrome DevTools Protocol. The Chrome DevTools Protocol uses WebSocket for communication, making frequent round-trips inefficient and less stable.</p><p>Here is an optimized version based on methods learned from ChatGPT:</p><pre>// FetchSchedule fetches the schedule from CPBL website based on the year, month, and game type<br>func FetchSchedule(year int, month int, gameType string) ([]GameSchedule, error) {<br>    ctx, cancel := chromedp.NewContext(context.Background())<br>    defer cancel()<br><br>    var schedules []GameSchedule<br><br>    // Define the URL<br>    url := &quot;https://cpbl.com.tw/schedule&quot;<br><br>    // Run chromedp tasks<br>    err := chromedp.Run(ctx,<br>        chromedp.Navigate(url),<br>        chromedp.WaitReady(`.ScheduleTableList`), // Wait for year select to be ready<br>        chromedp.Evaluate(fmt.Sprintf(&quot;document.querySelector(&#39;#Center&#39;).__vue__.filters.kindCode = &#39;%s&#39;&quot;, gameType), nil),<br>        chromedp.Evaluate(fmt.Sprintf(&quot;document.querySelector(&#39;#Center&#39;).__vue__.calendar.year = %d&quot;, year), nil),<br>        chromedp.WaitReady(`.ScheduleTableList`), // Wait for year select to be ready<br>        chromedp.Evaluate(fmt.Sprintf(&quot;document.querySelector(&#39;#Center&#39;).__vue__.calendar.month = %d&quot;, month-1), nil),<br>        chromedp.Evaluate(`document.querySelector(&#39;#Center&#39;).__vue__.getGameDatas()`, nil), // Wait for table to be visible<br>        chromedp.Sleep(2*time.Second), // Wait for table to load<br>        chromedp.Evaluate(`<br>            (() =&gt; {<br>                let schedules = [];<br>                document.querySelectorAll(&#39;.ScheduleTable tbody .date&#39;).forEach(dateDiv =&gt; {<br>                    let date = dateDiv.innerText.trim();<br>                    let parent = dateDiv.parentNode;<br>                    parent.querySelectorAll(&#39;.game&#39;).forEach(gameDiv =&gt; {<br>                        let location = gameDiv.querySelector(&#39;.place&#39;) ? gameDiv.querySelector(&#39;.place&#39;).innerText.trim() : &#39;&#39;;<br>                        let game_no = gameDiv.querySelector(&#39;.game_no&#39;) ? gameDiv.querySelector(&#39;.game_no&#39;).innerText.trim() : &#39;&#39;;<br>                        let away_team = gameDiv.querySelector(&#39;.team.away span&#39;) ? gameDiv.querySelector(&#39;.team.away span&#39;).title.trim() : &#39;&#39;;<br>                        let home_team = gameDiv.querySelector(&#39;.team.home span&#39;) ? gameDiv.querySelector(&#39;.team.home span&#39;).title.trim() : &#39;&#39;;<br>                        let score = gameDiv.querySelector(&#39;.score&#39;) ? gameDiv.querySelector(&#39;.score&#39;).innerText.trim() : &#39;&#39;;<br>                        let remark = gameDiv.querySelector(&#39;.remark .note div&#39;) ? gameDiv.querySelector(&#39;.remark .note div&#39;).innerText.trim() : &#39;&#39;;<br>                        schedules.push({ date, location, game_no, away_team, home_team, score, remark });<br>                    });<br>                });<br>                return schedules;<br>            })()<br>        `, &amp;schedules),<br>    )<br><br>    if err != nil {<br>        return nil, err<br>    }<br><br>    return schedules, nil<br>}</pre><p>This version extensively uses chromedp.Evaluate to embed JavaScript code directly in the web page, modifying Vue&#39;s internal values and directly returning the execution results to the Go program. This improves readability and avoids excessive communication with Chrome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=660feee9126a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/juliansplayground/crawling-dynamic-websites-using-chromedp-in-go-660feee9126a">Crawling Dynamic Websites Using chromedp in Go</a> was originally published in <a href="https://medium.com/juliansplayground">Julian’s Playground</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>