爬twitter(X)

2024-02-25  本文已影响0人  sexy_cyber
from twikit import Client
username, password = '@d99','xxx'
proxy = 'http://www.xx.proxy:25'
proxies = {
    'http://': proxy,
    'https://': proxy
}
USERNAME = username
EMAIL = 'xx@gmail.com'   #新IP登录需要邮箱接验证码
PASSWORD = password

# Initialize client
client = Client(
    'en-US',
    proxies=proxies
)
# Login to the service with provided user credentials
client.login(
    auth_info_1=USERNAME ,
    auth_info_2=EMAIL,
    password=PASSWORD
)
tweets = client.search_tweet('sora', 'Top')
for t in tweets:
    # t.text
    print(t.text)

每次都登陆肯定不行,得保存cooKies,通过cooKies登录

要是每次都以密码方式登录,应该很容易触发风控,有被封号的风险;


cookie_path = 'twitter_cookies.json'
client.save_cookies(cookie_path)
client = Client(
    'en-US',
    proxies=proxies
)
client.load_cookies(cookie_path)
上一篇下一篇

猜你喜欢

热点阅读