Charlie Harvey

Finding Twitter follower count with YQL instead of the Twitter API

Earlier today, a user, @pur_wie asked me if there was a way to get follower counts from Twitter.

Depending on your use case, I suppose you could try Twitter’s closed API. But OAuth is a faff. The quickest thing to do would be to crack out Yahoo’s YQL tool and screen scrape the data. I boshed together this little YQL expression that does the job*%20from%20html%20where%20url=""%20AND%20xpath="//li[contains(@class,'ProfileNav-item--followers')]/a/span[@class='ProfileNav-value']|//li[contains(@class,'ProfileNav-item--following')]/a/span[@class='ProfileNav-value']"

However, @pur_wie also needed a count of the users Tweets, which meant evolving the xpath expression a bit.*%20from%20html%20where%20url=""%20AND%20xpath="//li[contains(@class,'ProfileNav-item--followers')]/a/span[@class='ProfileNav-value']|//li[contains(@class,'ProfileNav-item--following')]/a/span[@class='ProfileNav-value']|//li[contains(@class,'ProfileNav-item--tweets')]/a/span[@class='ProfileNav-value']"

A proof of concept

It occurred to me that I could very easily wrap this in a bit of jQuery and make a little tool for putting together the tweets. So here it is. You can type a twitter username into the box and find out how many times they have tweeted, how many followers they have got and how many people they follow.

Username: @


  • Be respectful. You may want to read the comment guidelines before posting.
  • You can use Markdown syntax to format your comments. You can only use level 5 and 6 headings.
  • You can add class="your language" to code blocks to help highlight.js highlight them correctly.

Privacy note: This form will forward your IP address, user agent and referrer to the Akismet, StopForumSpam and Botscout spam filtering services. I don’t log these details. Those services will. I do log everything you type into the form. Full privacy statement.