小编dja*_*mes的帖子

PyMongo 集合对象不可调用

我正在尝试创建一个 Reddit 抓取工具,它从 Reddit 主页获取前 100 页并将它们存储到 MongoDB 中。我不断收到错误:

TypeError: 'Collection' object is not callable. If you meant to call the 'insert_one' method on a 'Collection' object it is failing because no such method exists.
Run Code Online (Sandbox Code Playgroud)

这是我的代码

import pymongo
import praw
import time


def main():
    fpid = os.fork()
    if fpid!=0:
        # Running as daemon now. PID is fpid
        sys.exit(0)

    user_agent = ("Python Scraper by djames v0.1")
    r = praw.Reddit(user_agent = user_agent)    #Reddit API requires user agent

    conn=pymongo.MongoClient()
    db = conn.reddit
    threads …
Run Code Online (Sandbox Code Playgroud)

python mongodb pymongo python-2.7

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

mongodb ×1

pymongo ×1

python ×1

python-2.7 ×1