Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spider_Python项目连接mongodb时出错 #4

Open
xyz-blue opened this issue Feb 24, 2018 · 1 comment
Open

Spider_Python项目连接mongodb时出错 #4

xyz-blue opened this issue Feb 24, 2018 · 1 comment

Comments

@xyz-blue
Copy link

我最近也在学习下Python的网络爬虫,非常感谢你的分享。
我今天在搭建好环境后尝试Spider_Python项目时遇到一个问题,无法连接mongodb,提示的错误是pymongo不存在Connection模块,然后我在网上找了下pymongo的用法,做了如下修改后可以正常运行并存入mongodb。
# 连接数据库,db和posts为数据库和集合的游标 def Connection(self): #connect to mongo(localhost:27017) mongoclient = pymongo.MongoClient() mongodb = mongoclient[self.database] posts = mongodb.posts return posts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@xyz-blue and others