python twitter爬网(抓取)JSON错误
是的。(Pip安装json,Pip安装simplejson) 但是,也会出现错误python twitter爬网(抓取)JSON错误,python,json,twitter,web-scraping,web-crawler,Python,Json,Twitter,Web Scraping,Web Crawler,是的。(Pip安装json,Pip安装simplejson) 但是,也会出现错误 simplejson.scanner.JSONDecodeError:从以下位置开始的未终止字符串: 第1行第65922列(字符65921) tweepy.error.TweepError:未能解析JSON有效负载:从第1行第65922列(char 65921)开始的未终止字符串 我该怎么办 import tweepy import time import os import json import simpl
- simplejson.scanner.JSONDecodeError:从以下位置开始的未终止字符串: 第1行第65922列(字符65921)
- tweepy.error.TweepError:未能解析JSON有效负载:从第1行第65922列(char 65921)开始的未终止字符串
import tweepy
import time
import os
import json
import simplejson
search_term = 'word1'
search_term2= 'word2'
search_term3='word3'
lat = "xxxx"
lon = "xxxx"
radius = "xxxx"
location = "%s,%s,%s" % (lat, lon, radius)
API_key = "xxxx"
API_secret = "xxxx"
Access_token = "xxxx"
Access_token_secret = "xxxx"
auth = tweepy.OAuthHandler(API_key, API_secret)
auth.set_access_token(Access_token, Access_token_secret)
api = tweepy.API(auth)
c=tweepy.Cursor(api.search,
q="{}+OR+{}".format(search_term, search_term2, search_term3),
rpp=1000,
geocode=location,
include_entities=True)
data = {}
i = 1
for tweet in c.items():
data['text'] = tweet.text
print(i, ":", data)
i += 1
time.sleep(1)
wfile = open(os.getcwd()+"/workk2.txt", mode='w')
data = {}
i = 0
for tweet in c.items():
data['text'] = tweet.text
wfile.write(data['text']+'\n')
i += 1
wfile.close()
除非您的python非常旧,否则您不需要
pip安装simplejson
或pip安装json
,json是内置的;并请发布完整的回溯(整个错误消息)。感谢您的评论。我要回家把节目放回去。我将提出错误的全部内容。请稍候。(T-T)@BurhanKhalid如果我在写评论,请再次回答。(ToT)除非您的python非常旧,否则您不需要pip安装simplejson
或pip安装json
,json是内置的;并请发布完整的回溯(整个错误消息)。感谢您的评论。我要回家把节目放回去。我将提出错误的全部内容。请稍候。(T-T)@BurhanKhalid如果我在写评论,请再次回答。(ToT)