<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Python3 on 春江暮客</title>
    <link>https://www.bobobk.com/en/tags/python3/</link>
    <description>Recent content in Python3 on 春江暮客</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Thu, 17 Jan 2019 03:21:06 +0000</lastBuildDate>
    <atom:link href="https://www.bobobk.com/en/tags/python3/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Drawing a Stunning &#34;Dream of the Red Chamber&#34; Word Cloud with Python 3</title>
      <link>https://www.bobobk.com/en/252.html</link>
      <pubDate>Thu, 17 Jan 2019 03:21:06 +0000</pubDate>
      <guid>https://www.bobobk.com/en/252.html</guid>
      <description>&lt;p&gt;Word clouds, which I&amp;rsquo;m sure you&amp;rsquo;ve all seen, are created using &lt;strong&gt;wordcloud&lt;/strong&gt;, a famous Python library. This article will detail how to use &lt;strong&gt;wordcloud&lt;/strong&gt; to create a word cloud for &amp;ldquo;Dream of the Red Chamber,&amp;rdquo; one of China&amp;rsquo;s Four Great Classical Novels.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;h1 id=&#34;1-preparation&#34;&gt;1. Preparation&lt;/h1&gt;&#xA;&lt;p&gt;This involves three parts:&lt;/p&gt;&#xA;&lt;h4 id=&#34;2-the-wordcloud-and-jieba-libraries-which-can-be-installed-using-pip-install-wordcloud-and-pip-install-jieba&#34;&gt;2. The &lt;strong&gt;wordcloud&lt;/strong&gt; and &lt;strong&gt;jieba&lt;/strong&gt; libraries, which can be installed using &lt;code&gt;pip install wordcloud&lt;/code&gt; and &lt;code&gt;pip install jieba&lt;/code&gt;.&lt;/h4&gt;&#xA;&lt;h4 id=&#34;3-preparing-a-chinese-font-file&#34;&gt;3. Preparing a Chinese font file.&lt;/h4&gt;&#xA;&lt;h4 id=&#34;the-txt-text-file-and-font-file-are-bundled-together-for-your-convenience-to-replicate-this-tutorials-example&#34;&gt;The &lt;code&gt;.txt&lt;/code&gt; text file and font file are bundled together for your convenience to replicate this tutorial&amp;rsquo;s example.&lt;/h4&gt;&#xA;&lt;hr&gt;&#xA;&lt;h1 id=&#34;2-drawing-the-dream-of-the-red-chamber-word-cloud&#34;&gt;2. Drawing the &amp;ldquo;Dream of the Red Chamber&amp;rdquo; Word Cloud&lt;/h1&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s the code directly:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;from&lt;/span&gt; wordcloud &lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; WordCloud&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; jieba&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    text &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;join(jieba&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;cut(open(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;红楼梦.txt&amp;#34;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;read()))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    wordcloud &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; WordCloud(font_path&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;kaibold.ttf&amp;#34;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;generate(text)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;# Display the generated image:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    plt&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;imshow(wordcloud, interpolation&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;bilinear&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    plt&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;axis(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;off&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    plt&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;margins(x&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;, y&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    plt&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;show()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/01/wordcloud_raw.webp&#34; alt=&#34;《Drawing a Stunning “Dream of the Red Chamber” Word Cloud with Python 3》&#34;&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python implementation for Qianqian Music MP3 download</title>
      <link>https://www.bobobk.com/en/216.html</link>
      <pubDate>Tue, 08 Jan 2019 05:31:43 +0000</pubDate>
      <guid>https://www.bobobk.com/en/216.html</guid>
      <description>&lt;p&gt;Entering the Qianqian Music homepage and selecting Jay Chou&amp;rsquo;s &amp;ldquo;Confession Balloon&amp;rdquo; reveals that it&amp;rsquo;s a 2016 song with no preview available, which is sad. Is there a way to get the MP3 file? The answer is yes. A runnable program for music download is available at the end of the article.&lt;/p&gt;&#xA;&lt;p&gt;Without further ado, I opened the charts and chose a new song that could be previewed; &amp;ldquo;Sheng Pi Zi&amp;rdquo; was the first one I could listen to.&lt;/p&gt;&#xA;&lt;h2 id=&#34;python-implementation-for-qianqian-music-mp3-download&#34;&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/01/bangdan.webp&#34; alt=&#34;Python implementation for Qianqian Music MP3 download&#34;&gt;&lt;/h2&gt;&#xA;&lt;h2 id=&#34;1-analyze-api-information&#34;&gt;1. Analyze API information&lt;/h2&gt;&#xA;&lt;p&gt;Opening the developer tools, I found that music files are definitely submitted through an API. Among many requests, I found a request that could retrieve music files. See the image below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/01/music_net.webp&#34; alt=&#34;Python implementation for Qianqian Music MP3 download&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;Check the request details:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/01/qqyy_request.webp&#34; alt=&#34;Python implementation for Qianqian Music MP3 download&#34;&gt;&#xA;The &lt;strong&gt;songid&lt;/strong&gt; parameter can be found in the current URL: &lt;code&gt;http://music.taihe.com/song/611238837&lt;/code&gt;. It&amp;rsquo;s simple. &lt;code&gt;from&lt;/code&gt; should be &amp;ldquo;web&amp;rdquo; or &amp;ldquo;app&amp;rdquo;, etc. The &lt;code&gt;format&lt;/code&gt; defining the return data type doesn&amp;rsquo;t need to be changed. &lt;code&gt;method&lt;/code&gt; doesn&amp;rsquo;t need to be changed. The &lt;code&gt;_&lt;/code&gt; parameter is a 13-digit timestamp. &lt;code&gt;callback&lt;/code&gt; is the prefix of the returned JSON data. The &lt;code&gt;1546915161467&lt;/code&gt; after the underscore is a 13-digit timestamp, while the preceding &lt;code&gt;17200943498528136486&lt;/code&gt; is unknown. We&amp;rsquo;ll try to use the known parameters to see if we can retrieve information without changing the unknown content.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python implementation for Qianqian Music MP3 download</title>
      <link>https://www.bobobk.com/en/216.html</link>
      <pubDate>Tue, 08 Jan 2019 05:31:43 +0000</pubDate>
      <guid>https://www.bobobk.com/en/216.html</guid>
      <description>&lt;p&gt;Entering the Qianqian Music homepage and selecting Jay Chou&amp;rsquo;s &amp;ldquo;Confession Balloon&amp;rdquo; reveals that it&amp;rsquo;s a 2016 song with no preview available, which is sad. Is there a way to get the MP3 file? The answer is yes. A runnable program for music download is available at the end of the article.&lt;/p&gt;&#xA;&lt;p&gt;Without further ado, I opened the charts and chose a new song that could be previewed; &amp;ldquo;Sheng Pi Zi&amp;rdquo; was the first one I could listen to.&lt;/p&gt;&#xA;&lt;h2 id=&#34;python-implementation-for-qianqian-music-mp3-download&#34;&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/01/bangdan.webp&#34; alt=&#34;Python implementation for Qianqian Music MP3 download&#34;&gt;&lt;/h2&gt;&#xA;&lt;h2 id=&#34;1-analyze-api-information&#34;&gt;1. Analyze API information&lt;/h2&gt;&#xA;&lt;p&gt;Opening the developer tools, I found that music files are definitely submitted through an API. Among many requests, I found a request that could retrieve music files. See the image below:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/01/music_net.webp&#34; alt=&#34;Python implementation for Qianqian Music MP3 download&#34;&gt;&#xA;Check the request details:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/01/qqyy_request.webp&#34; alt=&#34;Python implementation for Qianqian Music MP3 download&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;The &lt;strong&gt;songid&lt;/strong&gt; parameter can be found in the current URL: &lt;code&gt;http://music.taihe.com/song/611238837&lt;/code&gt;. It&amp;rsquo;s simple. &lt;code&gt;from&lt;/code&gt; should be &amp;ldquo;web&amp;rdquo; or &amp;ldquo;app&amp;rdquo;, etc. The &lt;code&gt;format&lt;/code&gt; defining the return data type doesn&amp;rsquo;t need to be changed. &lt;code&gt;method&lt;/code&gt; doesn&amp;rsquo;t need to be changed. The &lt;code&gt;_&lt;/code&gt; parameter is a 13-digit timestamp. &lt;code&gt;callback&lt;/code&gt; is the prefix of the returned JSON data. The &lt;code&gt;1546915161467&lt;/code&gt; after the underscore is a 13-digit timestamp, while the preceding &lt;code&gt;17200943498528136486&lt;/code&gt; is unknown. We&amp;rsquo;ll try to use the known parameters to see if we can retrieve information without changing the unknown content.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Setting Python 3 as the Default Environment in Baota Panel</title>
      <link>https://www.bobobk.com/en/32.html</link>
      <pubDate>Fri, 16 Nov 2018 02:28:18 +0000</pubDate>
      <guid>https://www.bobobk.com/en/32.html</guid>
      <description>Baota Panel is a management panel that simplifies server administration via a web interface, boosting operational efficiency. It enables easy installation of essential web programs, website creation and management, FTP, database tools, a visual file manager, CPU, memory, and traffic monitoring charts, and scheduled tasks.</description>
    </item>
  </channel>
</rss>
