Get Tweet text (xpath query)
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x


I'd like an xpath query that returns the text of a Tweet, given a URL such as this:

It should not, however, return the text of any reply tweets.

Also, you should be able to test it here, and your solution should be a link to your solution on

Note that the Oraclize implementation seems different than others. Here's an example to get you started, which should work (and works on other Xpath implementations), but unfortunately on Oraclize it returns the text of the replies as well:

html(*[contains(@class, 'tweet-text')][1]//text())

(Just paste that into the oraclize website and hit "test query")

Thank you.

awarded to enderdba

Crowdsource coding tasks.

1 Solution

Winning solution

The problem is, you were using the wrong class selector, as tweet-text is the general class for all tweets. When you access a permalink using the URL from Twitter, it returns a class that points to the main tweet that the permalink is refering:

html([contains(@class, "permalink-tweet-container")]//p[contains(@class, "tweet-text")]//text())

As the given tweet, it returns:

["Just because I have more time to watch games doesn\u2019t mean my picks will be better, but here are my brackets this year: ", "https://", "", "\u00a0", ""]

Try it in

Hey Enderba, I've posted a follow-up to this question here if you're interested:
bevan 2 years ago