Ahmet Kucuk
Published in

Ahmet Kucuk

A Script to Download Images From Twitter

Recently, I decided to pull images from Twitter to use in my Deep Neural Network project. Apparently, it is not a good idea because of the noisy data which might be the topic of another post. In this post, I will share a simple Java Code that allow you to download images from Twitter.

The Code is available in Github.

To run the code, you need to have a Twitter Application Account so that you can get appropriate authentication token for the Twitter’s API.

I want to explain the code little. The code is using Twitter’s Streaming API with Twitter’s Java Client.

Once you get the authentication token, you just need to decide which terms will be tracked. And this is all. The Code will check if the tweet has appropriate image and if there is, it will download the image in a separate thread that you can specify the maximum number of threads. It will also take care of duplicate urls which is important because I saw in my own tests, there are lots of tweets with same image url.

If you want to specify other constraints like location, it is fairly simple and can be found in Twitter’s Streaming API documentation.

It is very naive approach to get images and not tested very well. I am sharing the code because It worked for me and it might be a starting point for your project!

--

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ahmet Kucuk

Ahmet Kucuk

Software Engineer in NYC

More from Medium

Attack on Titan: The First Season Part 1 (of 1)

Saturn 0.2.0 — the international update.

A screenshot of Saturn’s korean translations file.

test

How to Get Away from Reading-Slump