0
트위터에서 트윗을 가져 와서 결과를 JSON으로 변환하려고하는 MongoDB 데이터베이스에 저장하고 싶습니다.
이 내 코드tweepy 검색 결과를 JSON 양식으로 변환하는 방법
import tweepy
import json
import pymongo
from pymongo import MongoClient
client=MongoClient()
db=client.scholarship
APP_KEY = app key here
APP_SECRET = app secret here
OAUTH_TOKEN = access-token here
OAUTH_TOKEN_SECRET = token secret here
auth=tweepy.OAuthHandler(APP_KEY,APP_SECRET)
auth.set_access_token(OAUTH_TOKEN,OAUTH_TOKEN_SECRET)
api=tweepy.API(auth)
for tweet in tweepy.Cursor(api.search,q="scholarship",count=100,result_type="recent",include_entities=True,lang="en").items():
tweet=json.dumps(tweet)
try:
db.daily.insert(tweet)
except Exception as e:
print "there is a problem ",e
else:
print "inserted"
내가 오류
인상 형식 오류가 무엇입니까 (에 repr (O)를 + "직렬화 JSON 아니다")
serach의 반환 형식 인 이유는 중입니다 형태
(참여자 = 없음, 잘린 = 거짓, 텍스트 = u'RT @AnwenAb : @OralRobertsU 2016있는 MedPro 수신 Inc의 \ ufffdEducation 전원 \ ufffd에 장학금 신청 마감 2016 년 6 월 1 ', is_quote_status = False입니다)
필요 제안 와 여기서 할 수 있습니다.
감사합니다.