RSSHub: Twitter routes no longer work

路由地址

/twitter/user/:id/:routeParams?

完整路由地址

/twitter/user/:id/:routeParams?

相关文档

https://docs.rsshub.app/en/routes/social-media#user-timeline-3

预期是什么?

返回用户时间线.

实际发生了什么?

演示站:

Route requested: /user/DIYgod

Error message: Response code 429 (Too Many Requests): target website might be blocking our access, you can host your own RSSHub instance for a better usability.

Helpful Information to provide when opening issue: Path: /user/DIYgod Node version: v18.17.1 Git Hash: 0d0ec74

自建站: Server Timeout

本地:

Route requested: /user/DIYgod

Error message: Response code 404 (Not Found): target website might be blocking our access, you can host your own RSSHub instance for a better usability.

Helpful Information to provide when opening issue: Path: /user/DIYgod Node version: v18.17.0 Git Hash: 115a334

部署

RSSHub 演示 (https://rsshub.app)

部署相关信息

No response

额外信息

.

这不是重复的 issue

  • 我已经搜索了现有 issue,以确保该错误尚未被报告。

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 26 (7 by maintainers)

Most upvoted comments

If the situation continues, we may consider adding account credentials, just like https://github.com/zedeus/nitter/pull/830

用了 selenium,python 写大概就像下面这样,其中 turn_on_notification 是用 selenium 点击 Turn on notification 按钮参考

收到的通知里面就已经包含了全部内容,但 reply 和 likes 不会有通知。我是收到通知后,再用 twitter-api-client 这个来抓一下。

async def get_tweets():
    get_notifications = r"""
                    const callback = arguments[arguments.length - 1];
                    window.myServiceWorkerRegistration = await window.navigator.serviceWorker.getRegistration();
                    window.myNotifications = await window.myServiceWorkerRegistration.getNotifications();
                    window.myNotifications.forEach(noti => noti.close());
                    callback(window.myNotifications);
                    """
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})
    chrome_options.add_argument("--headless=new")
    driver = webdriver.Chrome(options=chrome_options)
    driver.get("https://twitter.com")
    with open('cookies.json', 'r') as f:
        cookies = json.load(f)
        for cookie in cookies:
            # set the sameSite attribute to 'Strict' to avoid the error
            if 'sameSite' in cookie:
                cookie['sameSite'] = 'Strict'
            driver.add_cookie(cookie)
    turn_on_notification(driver)
    driver.set_script_timeout(5)
    while True:
        notis = driver.execute_async_script(get_notifications)
        # 一般只会收到一个 notification
        for n in notis:
            # 推广的 scribe_target 不是 tweet,且 tag 一般为空 ""
            if n['data']['scribe_target'] == 'tweet':
                yield {'poster': n['title'], 'guid': n['tag'], 'link': n['data']['uri'], 'full_text': n['body'],
                       'created_at': n['timestamp']}
                break

        await asyncio.sleep(2)

If the situation continues, we may consider adding account credentials, just like zedeus/nitter#830

能否不采用轮询的方式,加入 account credentials 后,开启关注 twitter 账户的 notifications,收到该账户的发推通知后,再用 rsshub 抓取,这样是否就可以避免频繁抓取导致封号了?

我开启 notifications 后,在 firefox 浏览器上都能很及时收到,不知道 rsshub 能否模拟浏览器来接收通知。

use one of the nitter instances at https://status.d420.de/ – some of them have RSS

guest account branch in nitter is still WIP, but it works with some extra coding and infra

still 404

Closed in 9032153

For anyone else wondering how to implement this first run this script

#!/bin/bash

guest_token=$(curl -s -XPOST https://api.twitter.com/1.1/guest/activate.json -H 'Authorization: Bearer AAAAAAAAAAAAAAAAAAAAAFXzAwAAAAAAMHCxpeSDG1gLNLghVe8d74hl6k4%3DRUMF4xAQLsbeBhTSRrCiQpJtxoGWeyHrDb5te2jpGskWDFW82F' | jq -r '.guest_token')

flow_token=$(curl -s -XPOST 'https://api.twitter.com/1.1/onboarding/task.json?flow_name=welcome' \
          -H 'Authorization: Bearer AAAAAAAAAAAAAAAAAAAAAFXzAwAAAAAAMHCxpeSDG1gLNLghVe8d74hl6k4%3DRUMF4xAQLsbeBhTSRrCiQpJtxoGWeyHrDb5te2jpGskWDFW82F' \
          -H 'Content-Type: application/json' \
          -H "User-Agent: TwitterAndroid/10.10.0" \
          -H "X-Guest-Token: ${guest_token}" \
          -d '{"flow_token":null,"input_flow_data":{"flow_context":{"start_location":{"location":"splash_screen"}}}}' | jq -r .flow_token)

curl -s -XPOST 'https://api.twitter.com/1.1/onboarding/task.json' \
          -H 'Authorization: Bearer AAAAAAAAAAAAAAAAAAAAAFXzAwAAAAAAMHCxpeSDG1gLNLghVe8d74hl6k4%3DRUMF4xAQLsbeBhTSRrCiQpJtxoGWeyHrDb5te2jpGskWDFW82F' \
          -H 'Content-Type: application/json' \
          -H "User-Agent: TwitterAndroid/10.10.0" \
          -H "X-Guest-Token: ${guest_token}" \
          -d "{\"flow_token\":\"${flow_token}\",\"subtask_inputs\":[{\"open_link\":{\"link\":\"next_link\"},\"subtask_id\":\"NextTaskOpenLink\"}]}" | jq -c -r '.subtasks[0]|if(.open_account) then {oauth_token: .open_account.oauth_token, oauth_token_secret: .open_account.oauth_token_secret} else empty end'

it will output a guest token and token secret like this

{"oauth_token":"1719213587296620928-BsXY2RIJEw7fjxoNwbBemgjJhueK0m","oauth_token_secret":"N0WB0xhL4ng6WTN44aZO82SUJjz7ssI3hHez2CUhTiYqy"}

then add this to your .env file

TWITTER_OAUTH_TOKEN=1719213587296620928-BsXY2RIJEw7fjxoNwbBemgjJhueK0m
TWITTER_OAUTH_TOKEN_SECRET=N0WB0xhL4ng6WTN44aZO82SUJjz7ssI3hHez2CUhTiYqy

and restart RSSHub 👍

Wowowow, that’s big news. I wasn’t expecting this issue can be solved within this year. I haven’t tried it out yet, but again, very appreciated for maintainers of this wonderful project

Closed in 9032153c7de4c9ca189482d495696986e9795106

程序调试就只能你自己做了,说实话 turn_on_notification 那个函数代码都需要的话,我就不太建议你自己写了,就放弃吧。 我的代码有很多我自己的东西,没法发给你。