在没有身份验证的情况下抓取twitter前端api。
twitter-scraper的Python项目详细描述
推特刮板
twitter的api使用起来很烦人,而且有很多限制- 幸运的是,他们的前端(javascript)有自己的api,我对其进行了逆向工程。 没有API速率限制。没有限制。非常快。
您可以使用这个库轻松地获取任何用户的tweets文本。
对制作马尔可夫链非常有用。
用法
>>> fromtwitter_scraperimportget_tweets>>> fortweetinget_tweets('kennethreitz',pages=1):>>> print(tweet['text'])P.S. your API is a user interface s3monkey just hit 100 github stars! Thanks, y’all! I’m not sure what this /dev/fd/5 business is, but it’s driving me up the wall. …
看起来你可以可靠地请求多达25页的tweets(约486条tweets)。
马尔可夫例子
首先,安装markovify:
$ pipenv install markovify
>>> importmarkovify>>> tweets='\n'.join([t['text']fortinget_tweets('kennethreitz',pages=25)])>>> text_model=markovify.Text(tweets)>>> print(text_model.make_short_sentence(140))Wtf you can’t use APFS on a prototype for “django-heroku”, which does a lot out of me.
安装
$ pipenv install twitter-scraper
仅支持Python 3.6+。
许可证
麻省理工学院