GithubHelp home page GithubHelp logo

Comments (8)

sep2 avatar sep2 commented on May 18, 2024 1

我用的 zhihu_oauth 这个包,给你一段代码参考一下吧

from zhihu_oauth import ZhihuClient, Answer
from zhihu_oauth.oauth.token import ZhihuToken

ZhihuToken.from_dict(zhihu_config['token_json']).save(zhihu_config['token_file'])

client = ZhihuClient()

if os.path.isfile(zhihu_config['token_file']):
    client.load_token(zhihu_config['token_file'])

token_json 长这样

{
      "user_id": 1111111111111111111,
      "uid": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "access_token": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "lock_in": 1800,
      "expires_in": 15000000,
      "token_type": "bearer",
      "cookie": {
        "q_c0": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "z_c0": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
      },
      "unlock_ticket": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "refresh_token": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}

下面是我写的一段文档供参考:

如果提示需要手机登录,则电脑上打开知乎网页,按F12然后在调试窗口的console页中输入下方代码并回车,返回 undefined 即为成功。

window.addEventListener("beforeunload", function() { debugger; }, false)

接着打开调试窗口的network页,点击clear按钮清除所有记录。

接着在网页上用手机登录,登录后会触发调试窗口暂停,在 network 页中找到 sign_in 条目,
选中后从 response 中把内容复制出来,粘贴到 config.json 的 token_json 中覆盖原条目。

这个请求的body是加密的,暂时没找到自动发请求的方法,得手动复制。

from decryptlogin.

heysummon avatar heysummon commented on May 18, 2024

您好 请问有办法或其他工具解决这个问题吗?头疼

from decryptlogin.

sep2 avatar sep2 commented on May 18, 2024

可以手动解决,网页上登录以后在local storage里面把cookie复制出来

from decryptlogin.

heysummon avatar heysummon commented on May 18, 2024

您好 获取的cookie应该加到哪里呢?新手入门

from decryptlogin.

sep2 avatar sep2 commented on May 18, 2024

加密方法估计和 https://github.com/CharlesPikachu/DecryptLogin/blob/master/DecryptLogin/platforms/zhihu.py 是一样的,但是目前没时间研究了,如果有人解决了希望能共享一下。

from decryptlogin.

heysummon avatar heysummon commented on May 18, 2024

非常谢谢您的回答!非常用心的回答,帮助很大!

from decryptlogin.

CharlesPikachu avatar CharlesPikachu commented on May 18, 2024

晚上我会publish DecryptLogin v0.2,里面支持知乎的扫码登录,这样就不需要每次复制cookies了。(因为后续再升级版本的话想在mode里直接加入短信验证码登录功能,所以暂时没去解决账号安全需要短信验证这个问题,新版本会临时disable pc端用账号密码登录知乎)
另外一个解决方案就是绑定邮箱,用邮箱+密码登录~

from decryptlogin.

CharlesPikachu avatar CharlesPikachu commented on May 18, 2024

new version is published, so I closed this issue.

feel free to reopen this issue if you have any questions about this issue again.

from decryptlogin.

Related Issues (20)

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.