Skip to content

Commit 931fe0c

Browse files
committed
readme
1 parent ba72000 commit 931fe0c

1 file changed

Lines changed: 59 additions & 72 deletions

File tree

README.rst

Lines changed: 59 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ zhihu-python:获取知乎信息
22
===============================
33

44
:Author: `egrcc <https://github.com/egrcc>`_ ( `微博 <http://weibo.com/u/2948739432>`_ | `电邮 <zhaolujun1994@gmail.com>`_ )
5-
:Committer: `Eureka22 <https://github.com/Eureka22>`_ , `lufo816 <https://github.com/lufo816>`_ , `LuoZijun <https://github.com/LuoZijun>`_
6-
:Update: 09/09 2015
5+
:Contributors: 参见 `Contributors <https://github.com/egrcc/zhihu-python/graphs/contributors>`_
6+
:Update: 04/23 2016
77

88

99
.. contents::
@@ -353,56 +353,10 @@ Collection 代表一个收藏夹,处理收藏夹相关操作。创建一个 Co
353353
# 代表所有答案的生成器对象
354354
355355
356-
Post:获取知乎文章
357-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358-
359-
Post 代表一个文章, Post 对象需传入该文章的 url ,如:
360-
361-
.. code-block:: python
362-
363-
from zhihu import Post
364-
365-
url = "http://zhuanlan.zhihu.com/p/20235601"
366-
post = Post(url)
367-
368-
得到 Post 对象后,可以获取该文章的一些信息:
369-
370-
.. code-block:: python
371-
372-
# -*- coding: utf-8 -*-
373-
from zhihu import Post
374-
375-
url = "http://zhuanlan.zhihu.com/p/20770968"
376-
post = Post(url)
377-
378-
# 获取该文章的标题
379-
title = post.get_title()
380-
# 获取该文章的内容
381-
content = post.get_content()
382-
# 获取该文章的作者
383-
author = post.get_author()
384-
# 获取该文章的所属专栏
385-
column = post.get_column()
386-
# 获取该文章所属话题
387-
topics = post.get_topics()
388-
389-
print title # 输出:夜读书|四月十九日
390-
print content
391-
# 输出:
392-
# <p>各位,晚上好。<br> ...
393-
# ......
394-
print author
395-
# 输出: <zhihu.User instance at 0x75ec0fd0>
396-
for topic in topics:
397-
print topic, # 输出:阅读
398-
print column
399-
# 输出:<zhihu.Column instance at 0x75eb3eb8>
400-
# Column类对象
401-
402356
Column:获取知乎专栏
403357
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404358

405-
Column 代表一个专栏 Column 对象需传入该专栏 url ,如:
359+
Column 代表一个专栏,创建一个 Column 对象需传入该专栏的 url ,如:
406360

407361
.. code-block:: python
408362
@@ -447,6 +401,54 @@ Column 代表一个专栏 Column 对象需传入该专栏 url ,如:
447401
# 输出:<generator object get_all_posts at 0x75e33bc0>
448402
# Post类对象
449403
404+
405+
Post:获取知乎文章
406+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407+
408+
Post 代表一个文章,创建一个 Post 对象需传入该文章的 url ,如:
409+
410+
.. code-block:: python
411+
412+
from zhihu import Post
413+
414+
url = "http://zhuanlan.zhihu.com/p/20235601"
415+
post = Post(url)
416+
417+
得到 Post 对象后,可以获取该文章的一些信息:
418+
419+
.. code-block:: python
420+
421+
# -*- coding: utf-8 -*-
422+
from zhihu import Post
423+
424+
url = "http://zhuanlan.zhihu.com/p/20770968"
425+
post = Post(url)
426+
427+
# 获取该文章的标题
428+
title = post.get_title()
429+
# 获取该文章的内容
430+
content = post.get_content()
431+
# 获取该文章的作者
432+
author = post.get_author()
433+
# 获取该文章的所属专栏
434+
column = post.get_column()
435+
# 获取该文章所属话题
436+
topics = post.get_topics()
437+
438+
print title # 输出:夜读书|四月十九日
439+
print content
440+
# 输出:
441+
# <p>各位,晚上好。<br> ...
442+
# ......
443+
print author
444+
# 输出: <zhihu.User instance at 0x75ec0fd0>
445+
for topic in topics:
446+
print topic, # 输出:阅读
447+
print column
448+
# 输出:<zhihu.Column instance at 0x75eb3eb8>
449+
# Column类对象
450+
451+
450452
综合实例
451453
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
452454

@@ -783,25 +785,25 @@ zhihu.Column ---- 知乎专栏操作类
783785

784786
**get_creator** ()
785787

786-
得到该专栏的创建者
788+
得到该专栏的创建者。
787789

788790
**Returns**: 一个 User 对象
789791

790792
**get_description** ()
791793

792-
得到该专栏的描述
794+
得到该专栏的描述
793795

794796
**Returns**: 一个专栏描述的字符串
795797

796798
**get_followers_num** ()
797799

798-
得到该专栏的关注人数
800+
得到该专栏的关注人数
799801

800802
**Returns**: 一个 int 型的整数
801803

802804
**get_posts_num** ()
803805

804-
得到该专栏的所有文章数
806+
得到该专栏的所有文章数
805807

806808
**Returns**: 一个 int 型的整数
807809

@@ -813,7 +815,7 @@ zhihu.Column ---- 知乎专栏操作类
813815

814816
**get_posts** ()
815817

816-
得到该专栏的所有文章
818+
得到该专栏的所有文章
817819

818820
**Returns**:包含所有文章的 generator 对象。其中每一个元素为代表一个文章 Post 对象
819821

@@ -838,13 +840,13 @@ zhihu.Post ---- 知乎文章操作类
838840

839841
**get_author** ()
840842

841-
得到该文章的作者
843+
得到该文章的作者。
842844

843845
**Returns**: 一个 User 对象
844846

845847
**get_content** ()
846848

847-
得到该文章的内容
849+
得到该文章的内容
848850

849851
**Returns**: 一个文章描述的字符串
850852

@@ -856,7 +858,7 @@ zhihu.Post ---- 知乎文章操作类
856858

857859
**get_column** ()
858860

859-
得到该文章的所属专栏
861+
得到该文章的所属专栏
860862

861863
**Returns**:一个 Column 的实例对象
862864

@@ -868,18 +870,3 @@ zhihu.Post ---- 知乎文章操作类
868870
- github:https://github.com/egrcc
869871
- email:zhaolujun1994@gmail.com
870872

871-
872-
捐赠
873-
----------
874-
875-
如果本项目有帮到你,欢迎捐赠支持。
876-
877-
支付宝(左),微信支付(右):
878-
879-
880-
.. image:: http://egrcc.github.io/img/alipay.jpg
881-
882-
.. image:: http://egrcc.github.io/img/wechat.png
883-
884-
885-

0 commit comments

Comments
 (0)