GithubHelp home page GithubHelp logo

zhihu-php's Introduction

zhihu-php 知乎数据解析 by PHP

介绍

zhihu-php 使用PHP编写,用于获取知乎上的各种信息。看了由 Python2.7 编写的 zhihu-python 想着自己用 PHP 写一个,于是有了这个项目。

本项目需要 PHP version >= 5.3 ,开启 CURL 扩展

根据 URL 生成对应的对象,例如知乎用户对象 User、知乎问题对象 Question、答案对象 Answer 等等。

准备

打开 zhihu.php,将知乎的 Cookie 复制黏贴到 COOKIE 的常量定义中:

define('COOKIE', "your cookie");

简单样例

<?php
require_one 'zhihu-php/zhihu.php';

$question_url = 'https://www.zhihu.com/question/19550393';
$question = new Question($question_url);

// 获取该问题排名第一的答案
$answer = $question->get_top_answer();

// 获取该回答的答主
$author = $answer->get_author();

// 获取答案答主的信息
$about = $author->get_about();

// 输出答主信息
var_dump($about);

zhihu-php's People

Contributors

ahonn avatar

Stargazers

 avatar

Watchers

Chang Wei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.