i trying pull json code urllib.request object focusing on twitter. doing out of curiosity , because trying determine request scrappy in order write code bypasses twitter's infinite scrolling , allows me pull tweets off user's timeline.
(i know there packages want set myself learn doing :) )
i have been using urllib package request data, however, have been running frustrating error when attempt it:
import json import urllib urllib.request.urlopen("https://twitter.com/vonkraush") url: data = url.read().decode() print(json.loads(data)) traceback (most recent call last): file "<ipython-input-30-208336effb36>", line 1, in <module> json.loads(data) file "c:\users\josh\anaconda3\lib\json\__init__.py", line 354, in loads return _default_decoder.decode(s) file "c:\users\josh\anaconda3\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) file "c:\users\josh\anaconda3\lib\json\decoder.py", line 357, in raw_decode raise jsondecodeerror("expecting value", s, err.value) none jsondecodeerror: expecting value i've tried expressly passing 'utf-8' decoding , few other methods, nothing has far allowed bypass error. doing wrong , how can fix it?
you doing wrong. url return html page. user data twitter use twitter dev api.
see here, twitter dev api might extract information twitter. have authenticate twitter user. make sure create twitter app first , oauth key. access twitter api.
twitter api uses token based authentication. token receive in response api call identity user.
Comments
Post a Comment