EN

Get Twitter Cookies

Social MediaMCP

Get Twitter (X) session cookies in the cloud from one account login or your browser cookies, ready for Octoparse's Twitter Follower & Following Scraper.

Templates are view-only on mobile. Please switch to a desktop to run this template.

📌 What is Get Twitter Cookies?

The Get Twitter Cookies template is an Octoparse tool that signs in to X (Twitter) in the cloud, or converts cookies you copied from your own browser, and returns the session cookies, a screenshot of the sign-in page, and an error field from that run. It helps you prepare a logged-in X session for Octoparse templates that require one, such as Twitter Follower & Following Scraper, without keeping a browser open on your own machine.

Data is collected from X (Twitter). X is a social network for public posts, profiles, and account relationships.


💰 Pricing

Get Twitter Cookies is free of charge and has no per-line usage fee. It is available on the Octoparse Standard plan or higher, and your plan's general resource limits still apply. See Octoparse pricing to compare what each plan includes.


📦 Output

Get Twitter Cookies returns these fields:

  • cookies: the Twitter session cookies, in the format that Twitter Follower & Following Scraper accepts in its Twitter Cookies field.
  • html: a screenshot of the X page reached during sign-in, delivered as an encoded image string, useful for checking whether X asked for extra verification.
  • error: a message explaining why a pasted cookie string was rejected, for example when auth_token is missing.

Ready to Start Scraping?

Paste your input, hit run, get structured data.


🎯 Use Cases

  • Unlock follower and following data: Generate the cookies that Twitter Follower & Following Scraper needs, then collect follower and following lists of the X accounts you track.
  • Recover from a blocked password login: When X challenges the password sign-in, convert the cookies from a browser session that is already logged in.
  • Renew an expired session: Re-run the template and compare the refreshed cookie payload with the old one before restarting a downstream task.
  • Troubleshoot sign-in problems: Check the html screenshot and the error field to see where the login stopped.

🐙 Why Octoparse

  • Built for the X login step: The template handles the sign-in that X requires before follower and following lists can be loaded, so you do not need to script the login yourself.
  • Two ways in: Sign in with a username and password, or reuse cookies from your own browser when the password route is blocked.
  • Ready for the follower workflow: The cookies field already matches the Twitter Cookies input of Twitter Follower & Following Scraper, so you can paste it straight in.
  • Cloud runs: The sign-in runs in Octoparse Cloud, not in a browser on your computer.
  • Part of a web data platform: Once the session works, schedule the downstream follower task, or run it through the Octoparse API or the Octoparse MCP server from your own apps and AI assistants.

📝 Input

  • Username (e.g. @elonmusk) (Required): Enter one X username in @username format, not an email address, because email sign-in can trigger an extra username check. Each run handles one account.
  • Password (Required): Enter the password for that X account. Octoparse uses it only to sign in to X during this run, and the password is not written into the output data. For extra safety, use a dedicated X account instead of your main one.
  • Cookies from Browser (Optional): Paste the cookie string copied from a browser where you are already logged in to X. It must include an auth_token value. Use it when X blocks or challenges the password sign-in.

Input and Output

Input

{
  "username": [
    "@elonmusk"
  ],
  "password": "example",
  "cookies_from_Browser": "example"
}

Output

[
  {
    "cookies": "[{'name': 'night_mode', 'value': '2'}, {'name': 'g_state', 'value': '{\"i_l\":0}'}, {'name': 'kdt', 'value': 'ZUEeEx86FZJZsevw5nurf9G4OjUK5RVY4BXm8hnP'}, {'name': 'dnt', 'value': '1'}, {'name': 'des_opt_in', 'value': 'Y'}, {'name': '_ga', 'value': 'GA1.2.568689135.1729744830'}, {'name': 'guest_id', 'value': 'v1%3A172981879665407960'}, {'name': 'guest_id_marketing', 'value': 'v1%3A172981879665407960'}, {'name': 'guest_id_ads', 'value': 'v1%3A172981879665407960'}, {'name': 'auth_token', 'value': '6316dd0b94a3893cf0886522f4f1b36ccbf9ddf3'}, {'name': 'ct0', 'value': '158ee749f7b565d1bef1ac962edb9708eea2beefa5888e3d94381011583125ad71ce21463fb0878904b9236104eeff65c4f7cf3d04fe1e845a5bed25d28e7d2bc1726bce585e968dda53924247ebff2c'}, {'name': 'twid', 'value': 'u%3D499321085'}, {'name': 'att', 'value': '1-nUESPh8KRxQeuhYaArT8i1zJIa1YfjKyRFrAGvSE'}, {'name': 'personalization_id', 'value': '\"v1_6VBscQVGqR/2LBi7I6amOg==\"'}, {'name': 'lang', 'value': 'en'}]"
  }
]

🚀 How to Use

  1. Create a free Octoparse account.
  2. Open Get Twitter Cookies and select Try it!.
  3. Enter one X username and its password, or paste a cookie string into Cookies from Browser.
  4. Start the task in Octoparse Cloud.
  5. Copy the cookies value from the results and paste it into the Twitter Cookies field of Twitter Follower & Following Scraper.

⚠️ Limitations

  • Each run accepts one X account.
  • Accounts that X asks to confirm with a phone number or email during sign-in will not finish through the password route, and the template does not retry or switch accounts automatically.
  • A Cookies from Browser string without a valid auth_token value is rejected and reported in the error field.
  • X cookies stop working once X ends the session, for example after you log out or change the account password.

💡 Tips

  • Linked workflow: Run Get Twitter Cookies first, copy the cookies value, paste it into the Twitter Cookies field of Twitter Follower & Following Scraper, then add up to 5,000 X account URLs whose followers or followings you want.
  • Stay logged in to X in the browser you copied cookies from. Logging out ends the session and the cookies stop working in downstream templates.
  • When Twitter Follower & Following Scraper reports an invalid or expired session, run Get Twitter Cookies again and replace the old value.
  • Use the @username, not the email address, to avoid the extra username check X shows for email sign-ins.

❓ FAQ

How do I get my Twitter cookies?

You have two options. Run Get Twitter Cookies with your X username and password in Octoparse Cloud, or copy the cookies from a browser where you are already logged in to X and paste them into the Cookies from Browser field, which the template converts into a reusable format.

How do I copy Twitter cookies from my browser for Cookies from Browser?

Log in to x.com in Chrome or Edge, press F12 to open Developer Tools, and open the Network tab. Refresh the page, select any request sent to x.com, and copy the full value of the Cookie request header. Paste that string into Cookies from Browser and make sure it contains auth_token.

auth_token is the X cookie that keeps your account signed in. Get Twitter Cookies requires it in any pasted cookie string, because without it the session cannot be reused by another template.

Does entering my X username and password return reusable session cookies?

The password route signs Octoparse in to X in the cloud and returns a screenshot of the sign-in page in the html field, which shows whether the login went through. To get a cookies value you can reuse in another template right away, paste an already logged-in cookie string into Cookies from Browser.

Is it safe to enter my X password in this template?

Octoparse uses the password only to sign in to X for the current run, and the password does not appear in the output data. Anyone holding your session cookies can act as your account, so keep the exported cookies private and consider a dedicated X account for data collection.

Which Octoparse templates use the cookies from Get Twitter Cookies?

Twitter Follower & Following Scraper uses them. X only shows follower and following lists to logged-in users, so that template needs your Twitter cookies in its Twitter Cookies field to load those lists and return user names, handles, profile URLs, and avatars.

Why did my X sign-in fail?

The most common reason is a verification prompt from X, such as a request for a phone number or email, which the password route cannot complete. Use Cookies from Browser with an already logged-in session instead.

How much does Get Twitter Cookies cost?

It is free of charge with no per-line usage fee, and it requires an Octoparse Standard plan or higher.