Code Monkey home page Code Monkey logo

Comments (3)

ly0 avatar ly0 commented on June 11, 2024

cookies对象必须是一个Cookiejar对象

from baidupcsapi.

abccbaandy avatar abccbaandy commented on June 11, 2024

我看了下 _save_cookies,發現 dict_from_cookiejar 其實只是把 cookiejar 轉成 hashmap ,格式剛好就是我上面的 cookies ,於是自己寫了個 converter 搭配 pickle.dump 轉成 .XXXX.cookies 就搞定了XD

附上code給有同樣需求的人,.test.cookies 改成自己的名字就OK了

import json
import pickle


# noinspection SpellCheckingInspection
def save_cookies(cookies):
    cookies_file = '.test.cookies'
    with open(cookies_file, 'wb') as f:
        pickle.dump(cookies, f)


def load_cookies():
    cookies = {}
    with open('export.json', 'r') as cookies_file:
        cookie_json = json.load(cookies_file)
        for cookie in cookie_json:
            cookies[cookie['name']] = cookie['value']
    return cookies


save_cookies(load_cookies())

from baidupcsapi.

HaoweiCh avatar HaoweiCh commented on June 11, 2024

有库可以直接读chrome或者firefox的用户cookie

from baidupcsapi.

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.