<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Soul Of Free Loop &#187; 阅读</title>
	<atom:link href="https://zohead.com/archives/tag/reading/feed/" rel="self" type="application/rss+xml" />
	<link>https://zohead.com</link>
	<description>Uranus Zhou&#039;s Blog</description>
	<lastBuildDate>Sat, 19 Jul 2025 15:42:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>简单PHP实现Pocket抓取知乎专栏文章</title>
		<link>https://zohead.com/archives/php-zhihu-pocket/</link>
		<comments>https://zohead.com/archives/php-zhihu-pocket/#comments</comments>
		<pubDate>Mon, 31 Oct 2016 16:03:50 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pocket]]></category>
		<category><![CDATA[专栏]]></category>
		<category><![CDATA[知乎]]></category>
		<category><![CDATA[阅读]]></category>

		<guid isPermaLink="false">https://zohead.com/?p=1293</guid>
		<description><![CDATA[Pocket 抓取知乎专栏的问题 Pocket 是我平时用的比较多的 稍后阅读 类网络服务，其收集抓取网上文章正文的效果比较好，去除页面广告等无关内容还算给力，支持标记和搜索，同步速度也还可以，免费会员限制也挺少，所以看到一些来不及马上阅读消化的文章我都会先加到 Pocket 队列里，有空时再去查看归档。 只是由于目前抓取网页正文原理的限制，Pocket 对现在越来越多的 AJAX 动态网页基本上都支持的不太好，比较典型的就是知乎专栏文章了。知乎专栏之前曾经是支持 Pocket 直接抓取的，改为 AJAX 加载数据之后，发送文章到 Pocket 之后就是这种效果： Pocket 正常抓取的文章 [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2 id="pocket-抓取知乎专栏的问题">Pocket 抓取知乎专栏的问题</h2>
<p><a href="https://getpocket.com/">Pocket</a> 是我平时用的比较多的 稍后阅读 类网络服务，其收集抓取网上文章正文的效果比较好，去除页面广告等无关内容还算给力，支持标记和搜索，同步速度也还可以，免费会员限制也挺少，所以看到一些来不及马上阅读消化的文章我都会先加到 Pocket 队列里，有空时再去查看归档。</p>
<p>只是由于目前抓取网页正文原理的限制，Pocket 对现在越来越多的 AJAX 动态网页基本上都支持的不太好，比较典型的就是知乎专栏文章了。知乎专栏之前曾经是支持 Pocket 直接抓取的，改为 AJAX 加载数据之后，发送文章到 Pocket 之后就是这种效果：</p>
<p><img src="http://res.cloudinary.com/digwht2y0/image/upload/v1737442877/pocket-zhihu-zl.png" alt="Pocket 抓取知乎专栏效果" title="Pocket 抓取知乎专栏效果"></p>
<p>Pocket 正常抓取的文章应该能显示摘要文字或者文章中的图片，知乎专栏文章则是空白的，而且点击文章条目也是直接跳转到知乎专栏链接，并没有显示 Pocket 抓取优化的效果。</p>
<h2 id="问题分析">问题分析</h2>
<p>稍微看看知乎专栏网页代码可以发现，如果在浏览器中访问类似这样的专栏文章链接：</p>
<p><a href="https://zhuanlan.zhihu.com/p/21542817">https://zhuanlan.zhihu.com/p/21542817</a></p>
<p>实际会加载下面的文章内容数据 API 链接，知乎专栏页面加载完数据之后才会显示：</p>
<p><a href="https://zhuanlan.zhihu.com/api/posts/21542817">https://zhuanlan.zhihu.com/api/posts/21542817</a></p>
<p>这种动态加载方式显然 Pocket 是不支持的，不过也好办，我们自己用 PHP 或者 Node.js 等实现一个简单的程序读取专栏文章内容并输出，然后放到 VPS 或者其它虚拟主机上运行，后面访问我自己的网址并发送到 Pocket 应该就可以使 Pocket 正确抓取了。另外这种方式比较好的一面就是输出内容里没有任何其它知乎相关的网页代码，只有专栏文章内容，更易于 Pocket 抓取处理。</p>
<h2 id="php-程序-pocket-抓取效果">PHP 程序 Pocket 抓取效果</h2>
<p>这个 PHP 程序实在没有什么技术含量，我就直接写一个简单的 PHP 文件接受传入专栏页面 ID 的 <code>page</code> 参数然后输出文章内容即可：</p>
<pre class="brush: php; title: zhihu.php; notranslate">
&lt;?php
if (!isset($_GET[&quot;page&quot;])) {
	echo &quot;need page id.&quot;;
	exit;
}

$PAGE_ID = $_GET[&quot;page&quot;];
$P_HEADERS = getallheaders();

if (array_key_exists(&quot;Referer&quot;, $P_HEADERS) || (isset($_GET[&quot;redirect&quot;]) &amp;&amp; $_GET[&quot;redirect&quot;] == '1')) {
	header(&quot;Location: https://zhuanlan.zhihu.com/p/&quot; . $PAGE_ID);
	exit;
}
?&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta name=&quot;referrer&quot; content=&quot;never&quot;/&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;/&gt;
&lt;?php
$PAGE_DATA = file_get_contents(&quot;https://zhuanlan.zhihu.com/api/posts/&quot; . $PAGE_ID);
$PAGE_OBJ = json_decode($PAGE_DATA);
echo '&lt;title&gt;' . $PAGE_OBJ-&gt;{&quot;title&quot;} . '&lt;/title&gt;';
?&gt;
&lt;link rel=&quot;shortcut icon&quot; href=&quot;https://static.zhihu.com/static/favicon.ico&quot; type=&quot;image/x-icon&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;
&lt;?php
echo $PAGE_OBJ-&gt;{&quot;title&quot;};
?&gt;
&lt;/h1&gt;
&lt;div&gt;
&lt;?php
echo $PAGE_OBJ-&gt;{&quot;content&quot;};
?&gt;
&lt;div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>上面的程序只是简单做了下判断，如果请求头中包含 Referer 信息（例如从 Pocket 网站跳转等）或者请求地址中 <code>redirect</code> 参数值为 <code>1</code> 就会直接跳转到知乎专栏页面，默认则输出专栏文章内容。另外程序中使用了 <code>getallheaders</code> 函数得到 HTTP 请求头信息，默认只支持 Apache，如果你要在 nginx 等服务器上使用则稍微修改下即可。</p>
<p> 另外程序中还将 <code>referrer</code> 值指定为 <code>never</code> 防止页面引用知乎图片等资源时触发知乎的防盗链机制。</p>
<p>把上面的 PHP 程序放到虚拟主机上，访问类似下面的链接（单纯演示用，需要翻墙哦）：</p>
<p><a href="http://devio.us/~nocwat/zhihu-grub.php?page=21542817">http://devio.us/~nocwat/zhihu-grub.php?page=21542817</a></p>
<p>正确显示文章内容后，将上面的链接发送到 Pocket 稍等片刻就能在 Pocket 队列里看到抓取的专栏文章了。</p>
<blockquote>
<p><strong>提示</strong></p>
<p>由于知乎专栏中的图片做了防盗链策略，直接访问上面的链接可能会出现文章中的图片不能正确显示的问题，不过没关系，Pocket 会自动为我们抓取保存文章中的图片的。</p>
</blockquote>
<p>最后来看看我的 Pocket 队列里的显示效果：</p>
<p><img src="http://res.cloudinary.com/digwht2y0/image/upload/v1737442877/pocket-php-zhihu.png" alt="Pocket 通过 PHP 抓取知乎专栏" title="Pocket 通过 PHP 抓取知乎专栏"></p>
<p>而且点击文章条目进入也能看到 Pocket 优化过的文章内容，在 Pocket 中点击 <strong>查看原始文档</strong> 也能自动跳转到知乎的专栏文章页面，这样再也不用担心专栏作者删除文章之后就没办法查看咯。</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/php-zhihu-pocket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>《The Alchemist》阅读摘录(1)</title>
		<link>https://zohead.com/archives/the-alchemist-snippet1/</link>
		<comments>https://zohead.com/archives/the-alchemist-snippet1/#comments</comments>
		<pubDate>Tue, 03 Jul 2012 14:46:49 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[心情随笔]]></category>
		<category><![CDATA[阅读]]></category>
		<category><![CDATA[书籍]]></category>
		<category><![CDATA[心灵]]></category>
		<category><![CDATA[梦想]]></category>
		<category><![CDATA[炼金术士]]></category>
		<category><![CDATA[童话]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=247</guid>
		<description><![CDATA[本文同步自（如浏览不正常请点击跳转）：https://zohead.com/archives/the-alchemist-snippet1/ 1、有关旅行 - Santiago 和其父亲的谈话： "People from all over the world have passed through this village, son," said his father. "They come in search of new things, but when they leave they are basically the same people they were when they ar [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>本文同步自（如浏览不正常请点击跳转）：<a href="https://zohead.com/archives/the-alchemist-snippet1/" target="_blank">https://zohead.com/archives/the-alchemist-snippet1/</a></p>
<p><strong><span style="color: #ff0000;">1、有关旅行 - Santiago 和其父亲的谈话：</span></strong></p>
<p>"People from all over the world have passed through this village, son," said his father. "They come in search of new things, but when they leave they are basically the same people they were when they arrived. They climb the mountain to see the castle, and they wind up thinking that the past was better than what we have now. They have blond hair, or dark skin, but basically they're the same as the people who live right here."</p>
<p>"But I'd like to see the castles in the towns where they live," the boy explained.</p>
<p>"Those people, when they see our land, say that they would like to live here forever," his father continued.</p>
<p>"Well, I'd like to see their land, and see how they live," said his son.</p>
<p>"The people who come here have a lot of money to spend, so they can afford to travel," his father said.</p>
<p>"Amongst us, the only ones who travel are the shepherds.""Well, then I'll be a shepherd!"His father said no more. The next day, he gave his son a pouch that held three ancient Spanish goldcoins.</p>
<p>"I found these one day in the fields. I wanted them to be a part of your inheritance. But use them to buy your flock. Take to the fields, and someday you'll learn that our countryside is the best, and ourwomen the most beautiful."</p>
<p><strong><span style="color: #ff0000;">2、有关梦 - 吉普赛女巫为 Santiago 解梦：</span></strong></p>
<p>"And the dreams are the language of God. When he speaks in our language, I can interpret what he has said. But if he speaks in the language of the soul, it is only you who can  understand. But, whichever it is, I'm going to charge you for the consultation."</p>
<p><strong><span style="color: #ff0000;">3、有关朋友 - Santiago 的感悟：</span></strong></p>
<p>If someone isn't what others want them to be, the others become angry. Everyone seems to have clear idea of how other people should lead their lives, but none about his or her own.</p>
<p><strong><span style="color: #ff0000;">4、有关命运 - Melchizedek（King of Salem）与 Santiago 的对话：</span></strong></p>
<p>The boy didn't know what a person's "destiny" was.</p>
<p>"It's what you have always wanted to accomplish. Everyone, when they are young, knows what their destiny is."</p>
<p>"At that point in their lives, everything is clear and everything is possible. They are not afraid to dream, and to yearn for everything they would like to see happen to them in their lives. But, as time passes, a mysterious force begins to convince them that it will be impossible for them to realize their destiny."</p>
<p>None of what the old man was saying made much sense to the boy. But he wanted to know what the"mysterious force" was; the merchant's daughter would be impressed when he told her about that!</p>
<p>"It's a force that appears to be negative, but actually shows you how to realize your destiny. It prepares your spirit and your will, because there is one great truth on this planet: whoever you are, or whatever it is that you do, when you really want something, it's because that desire originated in the soul of the universe. It's your mission on earth."</p>
<p>"Even when all you want to do is travel? Or marry the daughter of a textile merchant?"</p>
<p>"Yes, or even search for treasure. The Soul of the World is nourished by people's happiness. And also by unhappiness, envy, and jealousy. To realize one's destiny is a person's only real obligation. All things are one."</p>
<p>"And, when you want something, all the universe conspires in helping you to achieve it." They were both silent for a time, observing the plaza and the townspeople. It was the old man who spoke first.</p>
<p>"Why do you tend a flock of sheep?" "Because I like to travel."</p>
<p>The old man pointed to a baker standing in his shop window at one corner of the plaza. "When he was a child, that man wanted to travel, too. But he decided first to buy his bakery and put some money aside. When he's an old man, he's going to spend a month in Africa. He never realized that people are capable, at any time in their lives, of doing what they dream of." "He should have decided to become a shepherd," the boy said.</p>
<p>"Well, he thought about that," the old man said. "But bakers are more important people than shepherds. Bakers have homes, while shepherds sleep out in the open. Parents would rather see their children marry bakers than shepherds." The boy felt a pang in his heart, thinking about the merchant's daughter. There was surely a baker in her town.</p>
<p>The old man continued, "In the long run, what people think about shepherds and bakers becomes more important for them than their own destinies." The old man leafed through the book, and fell to reading a page he came to. The boy waited, and then interrupted the old man just as he himself had been interrupted. "Why are you telling me all this?" "Because you are trying to realize your destiny. And you are at the point where you're about to give it all up."</p>
<p>"And that's when you always appear on the scene?" "Not always in this way, but I always appear in one form or another. Sometimes I appear in the form of a solution, or a good idea. At other times, at a crucial moment, I make it easier for things to happen."</p>
<p>"There are other things I do, too, but most of the time people don't realize I've done them." The old man related that, the week before, he had been forced to appear before a miner, and had taken the form of a stone. The miner had abandoned everything to go mining for emeralds. For five years he had been working a certain river, and had examined hundreds of thousands of stones looking for an emerald. The miner was about to give it all up, right at the point when, if he were to examine just one more stone - just one more - he would find his emerald. Since the miner had sacrificed everything tohis destiny, the old man decided to become involved. He transformed himself into a stone that rolled up to the miner's foot. The miner, with all the anger and frustration of his five fruitless years, picked up the stone and threw it aside. But he had thrown it with such force that it broke the stone it fell upon, and there, embedded in the broken stone, was the most beautiful emerald in the world.</p>
<p>"People learn, early in their lives, what is their reason for being," said the old man, with a certain bitterness. "Maybe that's why they give up on it so early, too. But that's the way it is." The boy reminded the old man that he had said something about hidden treasure.</p>
<p>"Treasure is uncovered by the force of flowing water, and it is buried by the same currents," said the old man. "If you want to learn about your own treasure, you will have to give me one-tenth of your flock."</p>
<p>"What about one-tenth of my treasure?" The old man looked disappointed. "If you start out by promising what you don't even have yet, you'll lose your desire to work toward getting it." The boy told him that he had already promised to give one-tenth of his treasure to the Gypsy.</p>
<p>"Gypsies are experts at getting people to do that," sighed the old man. "In any case, it's good that you've learned that everything in life has its price. This is what the Warriors of the Light try to teach." The old man returned the book to the boy.</p>
<p>"Tomorrow, at this same time, bring me a tenth of your flock. And I will tell you how to find the hidden treasure. Good afternoon."And he vanished around the corner of the plaza.</p>
<p><strong><span style="color: #ff0000;">5、幸福的秘密 - Melchizedek 讲给 Santiago 的故事：</span></strong></p>
<p>"A certain shopkeeper sent his son to learn about the secret of happiness from the wisest man in the world. The lad wandered through the desert for forty days, and finally came upon a beautiful castle, high atop a mountain. It was there that the wise man lived.</p>
<p>"Rather than finding a saintly man, though, our hero, on entering the main room of the castle, saw hive of activity: tradesmen came and went, people were conversing in the corners, a small orchestra was playing soft music, and there was a table covered with platters of the most delicious food in that part of the world. The wise man conversed with everyone, and the boy had to wait for two hours before it was his turn to be given the man's attention.</p>
<p>"The wise man listened attentively to the boy's explanation of why he had come, but told him that he didn't have time just then to explain the secret of happiness. He suggested that the boy look around the palace and return in two hours.</p>
<p>" 'Meanwhile, I want to ask you to do something,' said the wise man, handing the boy a teaspoon that held two drops of oil. ' As you wander around, carry this spoon with you without allowing the oil to spill.'</p>
<p>"The boy began climbing and descending the many stairways of the palace, keeping his eyes fixed on the spoon. After two hours, he returned to the room where the wise man was.</p>
<p>" 'Well,' asked the wise man, 'did you see the Persian tapestries that are hanging in my dining hall?</p>
<p>Did you see the garden that it took the master gardener ten years to create? Did you notice the beautiful parchments in my library?'" The boy was embarrassed, and confessed that he had observed nothing. His only concern had been not to spill the oil that the wise man had entrusted to him.</p>
<p>" 'Then go back and observe the marvels of my world,' said the wise man. 'You cannot trust a man if you don't know his house.'</p>
<p>"Relieved, the boy picked up the spoon and returned to his exploration of the palace, this time observing all of the works of art on the ceilings and the walls. He saw the gardens, the mountains all around him, the beauty of the flowers, and the taste with which everything had been selected. Upon returning to the wise man, he related in detail everything he had seen.</p>
<p>" 'But where are the drops of oil I entrusted to you?' asked the wise man.</p>
<p>"Looking down at the spoon he held, the boy saw that the oil was gone.</p>
<p>" 'Well, there is only one piece of advice I can give you,' said the wisest of wise men. 'The secret of happiness is to see all the marvels of the world, and never to forget the drops of oil on the spoon.' The shepherd said nothing. He had understood the story the old king had told him. A shepherd may like to travel, but he should never forget about his sheep.</p>
<p><strong><span style="color: #ff0000;">6、被欺骗 - Santiago 被阿拉伯人骗去全部盘缠后的思考：</span></strong></p>
<p>He was so ashamed that he wanted to cry. He had never even wept in front of his own sheep. But the marketplace was empty, and he was far from home, so he wept. He wept because God was unfair, andbecause this was the way God repaid those who believed in their dreams.</p>
<p>When I had my sheep, I was happy, and I made those around me happy. People saw me coming and welcomed me, he thought. But now I'm sad and alone. I'm going to become bitter and distrustful of people because one person betrayed me. I'm going to hate those who have found their treasure because I never found mine. And I'm going to hold on to what little I have, because I'm too insignificant to conquer the world.</p>
<p>Now he understood why the owner of the bar had been so upset: he was trying to tell him not to trust that man. "I'm like everyone else - I see the world in terms of what I would like to see happen, not what actually does."</p>
<p>After all, what he had always wanted was just that: to know new places. Even if he never got to the Pyramids, he had already traveled farther than any shepherd he knew. Oh, if they only knew how different things are just two hours by ship from where they are, he thought. Although his new world at the moment was just an empty marketplace, he had already seen it when it was teeming with life, andhe would never forget it. He remembered the sword. It hurt him a bit to think about it, but he had never seen one like it before. As he mused about these things, he realized that he had to choose between thinking of himself as the poor victim of a thief and as an adventurer in quest of his treasure.</p>
<p>Looking around, he sought his sheep, and then realized that he was in a new world. But instead of being saddened, he was happy. He no longer had to seek out food and water for the sheep; he could go in search of his treasure, instead. He had not a cent in his pocket, but he had faith. He had decided, the night before, that he would be as much an adventurer as the ones he had admired in books.</p>
<p>He realized that he could do the same thing the old man had done - sense whether a person was near to or far from his destiny. Just by looking at them. It's easy, and yet I've never done it before, he thought.</p>
<p>He was learning a lot of new things. Some of them were things that he had already experienced, and weren't really new, but that he had never perceived before. And he hadn't perceived them because he had become accustomed to them. He realized: If I can learn to understand this language without words, I can learn to understand the world.</p>
<p>以上为看到的《The Alchemist》第一部分中的一些摘录，休息下之后再继续咯。</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/the-alchemist-snippet1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
