twitter-openapi-python 0.0.43__py3-none-any.whl → 0.0.45__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- twitter_openapi_python/__init__.py +15 -15
- twitter_openapi_python/api/__init__.py +13 -13
- twitter_openapi_python/api/default_api.py +80 -80
- twitter_openapi_python/api/initial_state_api.py +72 -72
- twitter_openapi_python/api/post_api.py +166 -166
- twitter_openapi_python/api/tweet_api.py +428 -353
- twitter_openapi_python/api/user_api.py +80 -80
- twitter_openapi_python/api/user_list_api.py +171 -171
- twitter_openapi_python/api/users_api.py +56 -56
- twitter_openapi_python/api/v11_get_api.py +67 -70
- twitter_openapi_python/api/v11_post_api.py +61 -66
- twitter_openapi_python/client.py +194 -194
- twitter_openapi_python/models/__init__.py +22 -22
- twitter_openapi_python/models/base.py +9 -9
- twitter_openapi_python/models/header.py +20 -20
- twitter_openapi_python/models/initial_state.py +17 -17
- twitter_openapi_python/models/response.py +19 -19
- twitter_openapi_python/models/timeline.py +40 -40
- twitter_openapi_python/tid.py +27 -17
- twitter_openapi_python/utils/__init__.py +22 -22
- twitter_openapi_python/utils/api.py +288 -288
- {twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/METADATA +118 -117
- twitter_openapi_python-0.0.45.dist-info/RECORD +27 -0
- {twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/WHEEL +1 -2
- {twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/licenses/LICENSE +31 -31
- {twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/licenses/LICENSE.AGPL +660 -660
- twitter_openapi_python-0.0.43.dist-info/RECORD +0 -28
- twitter_openapi_python-0.0.43.dist-info/top_level.txt +0 -1
{twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/METADATA
RENAMED
|
@@ -1,117 +1,118 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: twitter_openapi_python
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: Twitter OpenAPI
|
|
5
|
-
|
|
6
|
-
Author: fa0311
|
|
7
|
-
Author-email: yuki@yuki0311.com
|
|
8
|
-
License:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist:
|
|
16
|
-
Requires-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- [
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: twitter_openapi_python
|
|
3
|
+
Version: 0.0.45
|
|
4
|
+
Summary: Twitter OpenAPI
|
|
5
|
+
Keywords: twitter,api,python,scraper
|
|
6
|
+
Author: fa0311
|
|
7
|
+
Author-email: fa0311 <yuki@yuki0311.com>
|
|
8
|
+
License-Expression: LicenseRef-Custom OR AGPL-3.0-or-later
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LICENSE.AGPL
|
|
11
|
+
Requires-Dist: twitter-openapi-python-generated==0.0.35
|
|
12
|
+
Requires-Dist: pydantic>=2.6
|
|
13
|
+
Requires-Dist: requests>=2.31.0,<3.0.0
|
|
14
|
+
Requires-Dist: urllib3>=2.1.0,<3.0.0
|
|
15
|
+
Requires-Dist: xclienttransaction>=1.0.1,<2.0.0
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Project-URL: Repository, https://github.com/fa0311/twitter_openapi_python
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# twitter_openapi_python
|
|
21
|
+
|
|
22
|
+
Twitter scraping with data validation by pydantic.
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
## Setup
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
pip install twitter-openapi-python
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import json
|
|
36
|
+
import datetime
|
|
37
|
+
|
|
38
|
+
from pathlib import Path
|
|
39
|
+
from tweepy_authlib import CookieSessionUserHandler
|
|
40
|
+
from twitter_openapi_python import TwitterOpenapiPython
|
|
41
|
+
|
|
42
|
+
# login by tweepy_authlib
|
|
43
|
+
if Path("cookie.json").exists():
|
|
44
|
+
with open("cookie.json", "r") as f:
|
|
45
|
+
cookies_dict = json.load(f)
|
|
46
|
+
if isinstance(cookies_dict, list):
|
|
47
|
+
cookies_dict = {k["name"]: k["value"] for k in cookies_dict}
|
|
48
|
+
else:
|
|
49
|
+
auth_handler = CookieSessionUserHandler(
|
|
50
|
+
screen_name=input("screen_name: "),
|
|
51
|
+
password=input("password: "),
|
|
52
|
+
)
|
|
53
|
+
cookies_dict = auth_handler.get_cookies().get_dict()
|
|
54
|
+
|
|
55
|
+
# To extract cookies from Windows (Linux by default)
|
|
56
|
+
# If you use tweepy_authlib, you must be on Windows
|
|
57
|
+
client = TwitterOpenapiPython()
|
|
58
|
+
client.additional_api_headers = {
|
|
59
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
60
|
+
}
|
|
61
|
+
client.additional_browser_headers = {
|
|
62
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# get client from cookies
|
|
66
|
+
𝕏 = client.get_client_from_cookies(cookies=cookies_dict)
|
|
67
|
+
|
|
68
|
+
# tweet "Hello World!!" with current time
|
|
69
|
+
time = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
70
|
+
𝕏.get_post_api().post_create_tweet(tweet_text=f"Hello World!!{time}")
|
|
71
|
+
|
|
72
|
+
# get user info
|
|
73
|
+
response = 𝕏.get_user_api().get_user_by_screen_name("elonmusk")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Login
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from twitter_openapi_python import TwitterOpenapiPython
|
|
80
|
+
|
|
81
|
+
# guest client
|
|
82
|
+
𝕏 = TwitterOpenapiPython().get_guest_client()
|
|
83
|
+
tweet = 𝕏.get_default_api().get_tweet_result_by_rest_id("1349129669258448897")
|
|
84
|
+
assert tweet.data is not None
|
|
85
|
+
assert tweet.data.tweet.legacy is not None
|
|
86
|
+
print(tweet.data.tweet.legacy.full_text)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Multiple OS
|
|
90
|
+
|
|
91
|
+
The Token can only be used on the same OS that issued the Token
|
|
92
|
+
In other words, if the sec-ch-ua-platform does not match, the Token cannot be used.
|
|
93
|
+
This library uses the Linux Chrome header by default.
|
|
94
|
+
To use Token issued by Windows, do the following.
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
client = TwitterOpenapiPython()
|
|
98
|
+
client.additional_api_headers = {
|
|
99
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
100
|
+
};
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```shell
|
|
106
|
+
cd twitter_openapi_python
|
|
107
|
+
uv sync
|
|
108
|
+
uv run pytest test/api
|
|
109
|
+
uv build
|
|
110
|
+
uv publish
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
This project is dual licensed. You can choose one of the following licenses:
|
|
116
|
+
|
|
117
|
+
- [Custom License](./LICENSE)
|
|
118
|
+
- [GNU Affero General Public License v3.0](./LICENSE.AGPL)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
twitter_openapi_python/__init__.py,sha256=IyCanHNVJtKPGaYEMBqF37VXfMtZNUJlPhSOZMvO5jg,324
|
|
2
|
+
twitter_openapi_python/api/__init__.py,sha256=m9S_EoojMhead7EToafmdHKUxpyYHm9-qaKN_auWhSM,630
|
|
3
|
+
twitter_openapi_python/api/default_api.py,sha256=34l_jG5Mq1u0StPRX-QfGYHoGVYP8EEY_-5vFG_Xz7o,2586
|
|
4
|
+
twitter_openapi_python/api/initial_state_api.py,sha256=nAkb25-btWdMoSyyncxS_VrBQ9uKDgzmG7jBubfETYo,2269
|
|
5
|
+
twitter_openapi_python/api/post_api.py,sha256=uM-TzRKJQo5mFLXk8h8eu0zfYRXAvIZ0uRWA1eCnyuU,6526
|
|
6
|
+
twitter_openapi_python/api/tweet_api.py,sha256=F-oa2FJk4ySkUPkALp3cRindjsisbkCdyZh9XTLrRnQ,14178
|
|
7
|
+
twitter_openapi_python/api/user_api.py,sha256=AmGhdLrIidDwNn9eOmA3O0kYKbyustv3ZlrZdxTcvwc,2457
|
|
8
|
+
twitter_openapi_python/api/user_list_api.py,sha256=KYNYZfBFuvvZQERJcVjj5ZYc93tuCLNNOMv7r3dknOo,5502
|
|
9
|
+
twitter_openapi_python/api/users_api.py,sha256=8bcRi-kYZ9MtsgTxYDU1SnVqKtcyQ1b7QqWEVXVafqk,1750
|
|
10
|
+
twitter_openapi_python/api/v11_get_api.py,sha256=UXe34f6IBYExqWCJ8HCld_8d_ChQb92je0G5VtLxmyM,1978
|
|
11
|
+
twitter_openapi_python/api/v11_post_api.py,sha256=eErGBOo-y4E1AAMIHgeWnc0rAFmc5KgIoipJI-8V0Y8,1781
|
|
12
|
+
twitter_openapi_python/client.py,sha256=XkjUQYmewxYeTBl_IZng5Kz7pSmtgpaRg6bK9LCwXQ4,6786
|
|
13
|
+
twitter_openapi_python/models/__init__.py,sha256=Mt28XGFXzAauvwrjFhKyKpo2ZoN7uP_TMq-d9JuM9qk,561
|
|
14
|
+
twitter_openapi_python/models/base.py,sha256=3sw6wdQn9i8FoujFxhEFVWIB26-qjI6JTDuXKuebM0Y,189
|
|
15
|
+
twitter_openapi_python/models/header.py,sha256=EKujtBRZOJmeh2SD1QOCsLWaE9gdGY4wsNUgwCnbTCU,644
|
|
16
|
+
twitter_openapi_python/models/initial_state.py,sha256=XULKiYznCIG5TsLfV5RGPD_xOiE2bmKt1C8EtL-tQKM,513
|
|
17
|
+
twitter_openapi_python/models/response.py,sha256=ziBYbwdGSeCN3zfu5mFTTd8613zaZetzkZf8y_roTaI,461
|
|
18
|
+
twitter_openapi_python/models/timeline.py,sha256=uYCQWfI6nCTV6lzYse_ckACuQN_91Ucg-kmMcsbnoFE,1352
|
|
19
|
+
twitter_openapi_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
+
twitter_openapi_python/tid.py,sha256=xjqJMyPOp62nw2MQjMGHaB4L6G6OZHuWkMR-WKJo7aU,1120
|
|
21
|
+
twitter_openapi_python/utils/__init__.py,sha256=dCcm68kn5uv5rCRMLRd0rpeN6hAKulIz9khp0HLgx1c,427
|
|
22
|
+
twitter_openapi_python/utils/api.py,sha256=-fqJEcLOM4Y3UniSDxNldp8NCsgJ9vDPn4mQxOSOtyU,10122
|
|
23
|
+
twitter_openapi_python-0.0.45.dist-info/licenses/LICENSE,sha256=sLv8EMhrPCMG_LeweYvYKS_B-cDMBwBSKZel7LSMGAs,1493
|
|
24
|
+
twitter_openapi_python-0.0.45.dist-info/licenses/LICENSE.AGPL,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
|
|
25
|
+
twitter_openapi_python-0.0.45.dist-info/WHEEL,sha256=9IUYslYuG_asT4WlWvfk_K76nveuLvSTKDoLeL0cV-Q,80
|
|
26
|
+
twitter_openapi_python-0.0.45.dist-info/METADATA,sha256=_-Nw5lAAhfRaojF4MI3FYIA0E7ChFltIaIU-_oL5SDI,3234
|
|
27
|
+
twitter_openapi_python-0.0.45.dist-info/RECORD,,
|
{twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/licenses/LICENSE
RENAMED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
twitter-openapi License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 yuki
|
|
4
|
-
|
|
5
|
-
<https://yuki0311.com/>
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
The Software shall not be used for any activity that involves the following types
|
|
18
|
-
of behavior, commonly known as spam:
|
|
19
|
-
|
|
20
|
-
1. Sending unsolicited or excessive messages or posts.
|
|
21
|
-
2. Aggressively following, unfollowing, or liking tweets to artificially boost engagement.
|
|
22
|
-
3. Engaging in aggressive automated actions that disrupt or annoy other users.
|
|
23
|
-
4. Distributing false or misleading information.
|
|
24
|
-
|
|
25
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
-
SOFTWARE.
|
|
1
|
+
twitter-openapi License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 yuki
|
|
4
|
+
|
|
5
|
+
<https://yuki0311.com/>
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
The Software shall not be used for any activity that involves the following types
|
|
18
|
+
of behavior, commonly known as spam:
|
|
19
|
+
|
|
20
|
+
1. Sending unsolicited or excessive messages or posts.
|
|
21
|
+
2. Aggressively following, unfollowing, or liking tweets to artificially boost engagement.
|
|
22
|
+
3. Engaging in aggressive automated actions that disrupt or annoy other users.
|
|
23
|
+
4. Distributing false or misleading information.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|