How to monitor Twitter for user posting a new tweet

Hi.

Is there a way to track twitter feed without going down the RSS feed method. I have searched the forum but can’t see anything.

Full page doesnt work effectively for twitter as the column the trending section constantly changes. I can’t see a way to just select the stream of tweets in the centre of the page.

It maybe really obvious but im struggling to see it.

Cheers

Hi @neilbontoft, welcome to the community forum!

There are lots of dynamic contents in the Twitter feed, so automatically selecting them may cease to work after some time. If you want to monitor any account’s latest 5 tweets, then you can use the following config. It will work in the cloud.

{
  "selections": [
    {
      "frames": [
        {
          "index": 0,
          "excludes": [
            {
              "type": "css",
              "expr": "img"
            }
          ],
          "includes": [
            {
              "type": "css",
              "expr": "[data-testid=\"tweet\"] [lang] span"
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 10
    }
  ],
  "ignoreEmptyText": true,
  "includeStyle": false,
  "dataAttr": "text"
}
2 Likes

Thanks for this - seems to the trick for what I need.

1 Like

New user trying to monitor when a particular Twitter user posts a new tweet. I’m using the following as my config, and it almost works. The problem is that twitter changes up the “Promotional tweets” on a users page often. So even though a user hasn’t posted anything new, a change is still detected because the Promo tweet text has changed.

Is there a way I can exclude the promo tweets / only include tweets from the user in question?

{
  "selections": [
    {
      "frames": [
        {
          "index": 0,
          "excludes": [
            {
              "type": "css",
              "expr": "img"
            }
          ],
          "includes": [
            {
              "type": "css",
              "expr": "[data-testid=\"tweet\"] [lang] span"
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 10
    }
  ],
  "ignoreEmptyText": true,
  "includeStyle": false,
  "dataAttr": "text"
}
type or paste code here

Thanks for reaching out, Kyle. It should be possible to customize the config to filter out promoted tweets.

I was looking for one but could not stumble on one right now. Will you be able to share html code of a promoted tweet in a timeline? Browser’s inbuilt element inspector can be used to copy it. Let me know if you need any help getting that out. Cheers!

Thanks @ajitk,

I’ve attached a screenshot of the html for a promoted tweet. LMK if this is helpful or if another format would be more helpful.

Kyle

Got it, thanks. Can you try the following config? It excluded the promoted tweets using XPath expression:

{
  "selections": [
    {
      "frames": [
        {
          "index": 0,
          "excludes": [
            {
              "type": "css",
              "expr": "img"
            },
            {
              "type": "xpath",
              "expr": "//*[@data-testid='cellInnerDiv'][contains(text(), 'Promoted')]"
            }
          ],
          "includes": [
            {
              "type": "css",
              "expr": "[data-testid=\"tweet\"] [lang] span"
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 10
    }
  ],
  "ignoreEmptyText": true,
  "includeStyle": false,
  "dataAttr": "text"
}

Let me know if it works. Cheers!

@ajitk Thank you, but seems it’s not working quite yet. See below for examples (highlighted in green) of Promoted Tweet text still getting picked up and not excluded (Promoted tweets from GooglePixel and Tesla).

Is there anything else I can provide to help you investigate?

Another thought I had, is that the Promoted Tweets never appear in the first 2 tweets it seems. Is there a way to look at only the first two tweets, i.e. “[data-testid="tweet"] [lang] span” for only the first 2?

@ajitk any thoughts on whether limiting to top 2 tweets is possible?

Got to see a page with promoted tweet. So used that to create and test one. Checkout the following config that should be able to filter out the promoted tweets well:

{
  "selections": [
    {
      "frames": [
        {
          "index": 0,
          "excludes": [
            {
              "type": "css",
              "expr": "img,svg"
            }
          ],
          "includes": [
            {
              "type": "xpath",
              "expr": "//*[@data-testid='cellInnerDiv'][not(.//*[contains(text(), 'Promoted')])]//*[@data-testid='tweetText']",
              "fields": [
                {
                  "name": "text",
                  "type": "builtin"
                }
              ]
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 2
    }
  ],
  "ignoreEmptyText": true,
  "includeStyle": false,
  "dataAttr": "text"
}

Can you try this one out?

@ajitk Yes it seems to be working! Thanks so much, you’re a real wizard :slight_smile:

@ajitk One more thing seems to be happening, in that the check seems to be alternating how many tweets it’s checking against. See below where it’s adding/removing the tweet highlighted in green every other check. Is there a way to ensure it’s checking against the full timeline with every check?

Are you using the browser extension for checks? Some dynamic sites don’t load completely when opened in a background tab. They wait for the page to become “visible” to render completely.

Can you try using the desktop app instead? It doesn’t suffer from this limitation. Also, increase the delay in the config to a higher number, say 7 or 10. That should ensure that the page got enough time to load completely.

ajitk, any chance you could help me solve a similar situation, but with the @threads app instead of Twitter?

@legendarysubmit You can try out the following config for Threads

{
  "ignoreEmptyText": true,
  "includeStyle": false,
  "dataAttr": "text",
  "selections": [
    {
      "frames": [
        {
          "index": 0,
          "excludes": [],
          "includes": [
            {
              "type": "css",
              "expr": "[data-interactive-id] div:first-child div:first-child> [dir='auto']",
              "fields": [
                {
                  "name": "text",
                  "type": "builtin"
                }
              ]
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 2
    }
  ],
  "regexp": {
    "expr": "",
    "flags": "gim"
  }
}
1 Like