Skip to content

Commit f7ba81d

Browse files
committed
Merge branch 'v2beta'
2 parents a3cee34 + 005ba5e commit f7ba81d

40 files changed

+9139
-9479
lines changed

LICENSE

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) 2024 d60
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1+
MIT License
2+
3+
Copyright (c) 2024 d60
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.

README-ja.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="https://i.imgur.com/iJe6rsZ.png" width="500">
1+
<img src="https://i.imgur.com/iJe6rsZ.png" width="500">
22

33

44

@@ -34,10 +34,6 @@
3434

3535
このライブラリは、無料で使用することができます。
3636

37-
### 同期と非同期の両方に対応
38-
39-
同期と非同期の両方に対応しています。
40-
4137

4238
## 機能
4339

@@ -67,6 +63,7 @@ pip install twikit
6763
**クライアントを定義し、アカウントにログインする。**
6864

6965
```python
66+
import asyncio
7067
from twikit import Client
7168

7269
USERNAME = 'example_user'
@@ -76,25 +73,28 @@ PASSWORD = 'password0000'
7673
# Initialize client
7774
client = Client('en-US')
7875

79-
# アカウントにログイン
80-
client.login(
81-
auth_info_1=USERNAME ,
82-
auth_info_2=EMAIL,
83-
password=PASSWORD
84-
)
76+
async def main():
77+
# アカウントにログイン
78+
client.login(
79+
auth_info_1=USERNAME ,
80+
auth_info_2=EMAIL,
81+
password=PASSWORD
82+
)
83+
84+
asyncio.run(main())
8585
```
8686

8787
**メディア付きツイートを作成する。**
8888

8989
```python
9090
# メディアをアップロードし、メディアIDを取得する。
9191
media_ids = [
92-
client.upload_media('media1.jpg'),
93-
client.upload_media('media2.jpg')
92+
await client.upload_media('media1.jpg'),
93+
await client.upload_media('media2.jpg')
9494
]
9595

9696
# ツイートを投稿する
97-
client.create_tweet(
97+
await client.create_tweet(
9898
text='Example Tweet',
9999
media_ids=media_ids
100100
)
@@ -103,7 +103,7 @@ client.create_tweet(
103103

104104
**ツイートを検索する**
105105
```python
106-
tweets = client.search_tweet('python', 'Latest')
106+
tweets = await client.search_tweet('python', 'Latest')
107107

108108
for tweet in tweets:
109109
print(
@@ -115,7 +115,7 @@ for tweet in tweets:
115115

116116
**ユーザーのツイートを取得する**
117117
```python
118-
tweets = client.get_user_tweets('123456', 'Tweet')
118+
tweets = await client.get_user_tweets('123456', 'Tweet')
119119

120120
for tweet in tweets:
121121
print(tweet.text)

README-zh.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="https://i.imgur.com/iJe6rsZ.png" width="500">
1+
<img src="https://i.imgur.com/iJe6rsZ.png" width="500">
22

33

44

@@ -36,10 +36,6 @@
3636

3737
本库无需付费。
3838

39-
### 同步/异步支持
40-
41-
Twikit 同时提供同步和异步的实现。
42-
4339

4440
## 功能
4541

@@ -69,6 +65,7 @@ pip install twikit
6965
**定义一个客户端并登录**
7066

7167
```python
68+
import asyncio
7269
from twikit import Client
7370

7471
USERNAME = 'example_user'
@@ -78,24 +75,27 @@ PASSWORD = 'password0000'
7875
# 初始化客户端
7976
client = Client('en-US')
8077

81-
client.login(
82-
auth_info_1=USERNAME ,
83-
auth_info_2=EMAIL,
84-
password=PASSWORD
85-
)
78+
async def main():
79+
await client.login(
80+
auth_info_1=USERNAME ,
81+
auth_info_2=EMAIL,
82+
password=PASSWORD
83+
)
84+
85+
asyncio.run(main())
8686
```
8787

8888
**创建一条附带媒体的推文**
8989

9090
```python
9191
# 上传媒体文件并获取媒体ID
9292
media_ids = [
93-
client.upload_media('media1.jpg'),
94-
client.upload_media('media2.jpg')
93+
await client.upload_media('media1.jpg'),
94+
await client.upload_media('media2.jpg')
9595
]
9696

9797
# 创建一条带有提供的文本和附加媒体的推文
98-
client.create_tweet(
98+
await client.create_tweet(
9999
text='Example Tweet',
100100
media_ids=media_ids
101101
)
@@ -104,7 +104,7 @@ client.create_tweet(
104104

105105
**搜索推文**
106106
```python
107-
tweets = client.search_tweet('python', 'Latest')
107+
tweets = await client.search_tweet('python', 'Latest')
108108

109109
for tweet in tweets:
110110
print(
@@ -116,7 +116,7 @@ for tweet in tweets:
116116

117117
**检索用户的推文**
118118
```python
119-
tweets = client.get_user_tweets('123456', 'Tweet')
119+
tweets = await client.get_user_tweets('123456', 'Tweet')
120120

121121
for tweet in tweets:
122122
print(tweet.text)

0 commit comments

Comments
 (0)