easy-twitter-publisher


Nameeasy-twitter-publisher JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://easy-twitter-publisher.xink.top/
Summary简易、好用的推特(Twitter)发帖/回帖程序,支持图片,视频
upload_time2023-09-09 04:03:24
maintainer
docs_urlNone
authorhanxinkong
requires_python>=3.6.8
licenseMIT
keywords easy twitter publisher
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # easy_twitter_publisher

推特(Twitter)发帖回帖程序,支持本地及url图文(jpg,png,gif),视频(mp4),希望能为使用者带来益处。如果您也想贡献好的代码片段,请将代码以及描述,通过邮箱( [xinkonghan@gmail.com](mailto:hanxinkong<xinkonghan@gmail.com>)
)发送给我。代码格式是遵循自我主观,如存在不足敬请指出!

----
**文档地址:
** <a href="https://easy-twitter-publisher.xink.top/" target="_blank">https://easy-twitter-publisher.xink.top/ </a>

**PyPi地址:
** <a href="https://pypi.org/project/easy-twitter-publisher" target="_blank">https://pypi.org/project/easy-twitter-publisher </a>

**GitHub地址:
** [https://github.com/hanxinkong/easy-twitter-publisher](https://github.com/hanxinkong/easy-twitter-publisher)

----

## 推特三件套(有需要可自行安装)

- `easy_twitter_publisher` 推特发帖,回帖,转载 https://pypi.org/project/easy_twitter_publisher
- `easy_twitter_crawler` 推特采集 https://pypi.org/project/easy-twitter-crawler
- `easy_twitter_interactors` 推特互动(点赞,刷阅读量等) https://pypi.org/project/easy_twitter_interactors

## 安装

<div class="termy">

```console
pip install easy-twitter-publisher
```

</div>

## 主要功能

- `media_upload` 媒体文件上传(本地图片或视频)
- `media_upload_from_url` 媒体文件上传(url链接,仅支持gif及视频)
- `post` 发帖(支持文本,图片,视频)
- `reply` 回帖(支持文本,图片,视频)

## 简单使用

设置代理及cookie (发帖和回帖均需要设置cookie)

```python
proxy = {
    'http': 'http://127.0.0.1:10808',
    'https': 'http://127.0.0.1:10808'
}
cookie = 'auth_token=686fa28f49400698820d0a3c344c51efdeeaf73a; ct0=5bed99b7faad9dcc742eda564ddbcf37888f8794abd6d4d736919234440be2172da1e9a9fc48bb068db1951d1748ba5467db2bc3e768f122794265da0a9fa6135b4ef40763e7fd91f730d0bb1298136b'
```

媒体上传使用案例(内容需要图片或视频时使用此方法)

```python
from easy_spider_tool import format_json
from easy_twitter_publisher import TwitterMedia, get_headers

twitter_media = TwitterMedia()
twitter_media.set_headers(get_headers(cookie))
twitter_media.set_proxy(proxy)
# 本地文件
media_info = twitter_media.media_upload(r'0.gif')
# 图片链接
# twitter_media.media_upload_from_url('https://th.bing.com/th/id/R.466bb61cd7cf4e8b7d9cdf645add1d6e?rik=YRZKRLNWLutoZA&riu=http%3a%2f%2f222.186.12.239%3a10010%2fwmxs_161205%2f002.jpg&ehk=WEy01YhyfNzzQNe1oIqxwgbTnzY7dMfmZZHkqpZB5WI%3d&risl=&pid=ImgRaw&r=0')
print(format_json(media_info))
```

媒体上传参数说明

| 字段名        | 类型     | 必须 | 描述     |
|------------|--------|----|--------|
| media_path | string | 是  | 媒体文件路径 |

___

发帖使用案例(指定文本,图片发帖子)

```python
from easy_spider_tool import format_json
from easy_twitter_publisher import TwitterPost, get_headers

twitter_post = TwitterPost()
twitter_post.set_headers(get_headers(cookie))
twitter_post.set_proxy(proxy)

post_info = twitter_post.post(
    text="""Hi, I'm Han Xinkong""",
    # medias=[twitter_media.media_id]
)
print(format_json(post_info))
```

发帖参数说明

| 字段名    | 类型     | 必须 | 描述                  |
|--------|--------|----|---------------------|
| text   | string | 是  | 文本(最多不超过个字符,包括空格回车) |
| medias | list   | 否  | 媒体文件上传后的媒体id(可指定多个) |              

___

回帖使用案例(指定目标帖子,对其回帖)

```python
from easy_spider_tool import format_json
from easy_twitter_publisher import TwitterPost, get_headers

twitter_post = TwitterPost()
twitter_post.set_headers(get_headers(cookie))
twitter_post.set_proxy(proxy)

reply_info = twitter_post.reply(
    to_tweet_id='1690065356495421444',
    text="""Hi, I'm Han Xinkong""",
    # medias=[twitter_media.media_id]
)
print(format_json(reply_info))
```

回帖参数说明

| 字段名         | 类型     | 必须 | 描述                                                                                     |
|-------------|--------|----|----------------------------------------------------------------------------------------|
| to_tweet_id | string | 是  | 目标帖子id(https://twitter.com/elonmusk/status/1690164670441586688 中的 1690164670441586688) |
| text        | string | 是  | 文本(最多不超过个字符,包括空格回车)                                                                    |
| medias      | list   | 否  | 媒体文件上传后的媒体id(可指定多个)                                                                    |              

___

## 依赖

内置依赖

- `typing` Type Hints for Python.
- `os` Type Hints for Python.
- `imghdr` Type Hints for Python.
- `mimetypes` Type Hints for Python.
- `pathlib` Type Hints for Python.
- `json` Type Hints for Python.

第三方依赖

- `loguru` An XPath for JSON.
- `urllib3` An XPath for JSON.
- `requests` An XPath for JSON.
- `requests_toolbelt` Python library used for parsing dates from natural language text.
- `easy_spider_tool` Python library used for parsing dates from natural language text.

_注:依赖顺序排名不分先后_

## 链接

Github:https://github.com/hanxinkong/easy-twitter-publisher

在线文档:https://easy-twitter-publisher.xink.top

## 贡献者

## 许可证

该项目根据 **MIT** 许可条款获得许可.

            

Raw data

            {
    "_id": null,
    "home_page": "https://easy-twitter-publisher.xink.top/",
    "name": "easy-twitter-publisher",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.8",
    "maintainer_email": "",
    "keywords": "easy,twitter,publisher",
    "author": "hanxinkong",
    "author_email": "xinkonghan@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/11/44/961f9a2d8753118986f6d13a0106a044824fc3e3091cf84a67fb930b16e4/easy_twitter_publisher-1.0.3.tar.gz",
    "platform": null,
    "description": "# easy_twitter_publisher\r\n\r\n\u63a8\u7279\uff08Twitter\uff09\u53d1\u5e16\u56de\u5e16\u7a0b\u5e8f\uff0c\u652f\u6301\u672c\u5730\u53caurl\u56fe\u6587\uff08jpg,png,gif\uff09,\u89c6\u9891\uff08mp4\uff09\uff0c\u5e0c\u671b\u80fd\u4e3a\u4f7f\u7528\u8005\u5e26\u6765\u76ca\u5904\u3002\u5982\u679c\u60a8\u4e5f\u60f3\u8d21\u732e\u597d\u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u8bf7\u5c06\u4ee3\u7801\u4ee5\u53ca\u63cf\u8ff0\uff0c\u901a\u8fc7\u90ae\u7bb1\uff08 [xinkonghan@gmail.com](mailto:hanxinkong<xinkonghan@gmail.com>)\r\n\uff09\u53d1\u9001\u7ed9\u6211\u3002\u4ee3\u7801\u683c\u5f0f\u662f\u9075\u5faa\u81ea\u6211\u4e3b\u89c2\uff0c\u5982\u5b58\u5728\u4e0d\u8db3\u656c\u8bf7\u6307\u51fa\uff01\r\n\r\n----\r\n**\u6587\u6863\u5730\u5740\uff1a\r\n** <a href=\"https://easy-twitter-publisher.xink.top/\" target=\"_blank\">https://easy-twitter-publisher.xink.top/ </a>\r\n\r\n**PyPi\u5730\u5740\uff1a\r\n** <a href=\"https://pypi.org/project/easy-twitter-publisher\" target=\"_blank\">https://pypi.org/project/easy-twitter-publisher </a>\r\n\r\n**GitHub\u5730\u5740\uff1a\r\n** [https://github.com/hanxinkong/easy-twitter-publisher](https://github.com/hanxinkong/easy-twitter-publisher)\r\n\r\n----\r\n\r\n## \u63a8\u7279\u4e09\u4ef6\u5957\uff08\u6709\u9700\u8981\u53ef\u81ea\u884c\u5b89\u88c5\uff09\r\n\r\n- `easy_twitter_publisher` \u63a8\u7279\u53d1\u5e16,\u56de\u5e16,\u8f6c\u8f7d https://pypi.org/project/easy_twitter_publisher\r\n- `easy_twitter_crawler` \u63a8\u7279\u91c7\u96c6 https://pypi.org/project/easy-twitter-crawler\r\n- `easy_twitter_interactors` \u63a8\u7279\u4e92\u52a8\uff08\u70b9\u8d5e,\u5237\u9605\u8bfb\u91cf\u7b49\uff09 https://pypi.org/project/easy_twitter_interactors\r\n\r\n## \u5b89\u88c5\r\n\r\n<div class=\"termy\">\r\n\r\n```console\r\npip install easy-twitter-publisher\r\n```\r\n\r\n</div>\r\n\r\n## \u4e3b\u8981\u529f\u80fd\r\n\r\n- `media_upload` \u5a92\u4f53\u6587\u4ef6\u4e0a\u4f20\uff08\u672c\u5730\u56fe\u7247\u6216\u89c6\u9891\uff09\r\n- `media_upload_from_url` \u5a92\u4f53\u6587\u4ef6\u4e0a\u4f20\uff08url\u94fe\u63a5\uff0c\u4ec5\u652f\u6301gif\u53ca\u89c6\u9891\uff09\r\n- `post` \u53d1\u5e16\uff08\u652f\u6301\u6587\u672c\uff0c\u56fe\u7247\uff0c\u89c6\u9891\uff09\r\n- `reply` \u56de\u5e16\uff08\u652f\u6301\u6587\u672c\uff0c\u56fe\u7247\uff0c\u89c6\u9891\uff09\r\n\r\n## \u7b80\u5355\u4f7f\u7528\r\n\r\n\u8bbe\u7f6e\u4ee3\u7406\u53cacookie (\u53d1\u5e16\u548c\u56de\u5e16\u5747\u9700\u8981\u8bbe\u7f6ecookie)\r\n\r\n```python\r\nproxy = {\r\n    'http': 'http://127.0.0.1:10808',\r\n    'https': 'http://127.0.0.1:10808'\r\n}\r\ncookie = 'auth_token=686fa28f49400698820d0a3c344c51efdeeaf73a; ct0=5bed99b7faad9dcc742eda564ddbcf37888f8794abd6d4d736919234440be2172da1e9a9fc48bb068db1951d1748ba5467db2bc3e768f122794265da0a9fa6135b4ef40763e7fd91f730d0bb1298136b'\r\n```\r\n\r\n\u5a92\u4f53\u4e0a\u4f20\u4f7f\u7528\u6848\u4f8b\uff08\u5185\u5bb9\u9700\u8981\u56fe\u7247\u6216\u89c6\u9891\u65f6\u4f7f\u7528\u6b64\u65b9\u6cd5\uff09\r\n\r\n```python\r\nfrom easy_spider_tool import format_json\r\nfrom easy_twitter_publisher import TwitterMedia, get_headers\r\n\r\ntwitter_media = TwitterMedia()\r\ntwitter_media.set_headers(get_headers(cookie))\r\ntwitter_media.set_proxy(proxy)\r\n# \u672c\u5730\u6587\u4ef6\r\nmedia_info = twitter_media.media_upload(r'0.gif')\r\n# \u56fe\u7247\u94fe\u63a5\r\n# twitter_media.media_upload_from_url('https://th.bing.com/th/id/R.466bb61cd7cf4e8b7d9cdf645add1d6e?rik=YRZKRLNWLutoZA&riu=http%3a%2f%2f222.186.12.239%3a10010%2fwmxs_161205%2f002.jpg&ehk=WEy01YhyfNzzQNe1oIqxwgbTnzY7dMfmZZHkqpZB5WI%3d&risl=&pid=ImgRaw&r=0')\r\nprint(format_json(media_info))\r\n```\r\n\r\n\u5a92\u4f53\u4e0a\u4f20\u53c2\u6570\u8bf4\u660e\r\n\r\n| \u5b57\u6bb5\u540d        | \u7c7b\u578b     | \u5fc5\u987b | \u63cf\u8ff0     |\r\n|------------|--------|----|--------|\r\n| media_path | string | \u662f  | \u5a92\u4f53\u6587\u4ef6\u8def\u5f84 |\r\n\r\n___\r\n\r\n\u53d1\u5e16\u4f7f\u7528\u6848\u4f8b\uff08\u6307\u5b9a\u6587\u672c\uff0c\u56fe\u7247\u53d1\u5e16\u5b50\uff09\r\n\r\n```python\r\nfrom easy_spider_tool import format_json\r\nfrom easy_twitter_publisher import TwitterPost, get_headers\r\n\r\ntwitter_post = TwitterPost()\r\ntwitter_post.set_headers(get_headers(cookie))\r\ntwitter_post.set_proxy(proxy)\r\n\r\npost_info = twitter_post.post(\r\n    text=\"\"\"Hi, I'm Han Xinkong\"\"\",\r\n    # medias=[twitter_media.media_id]\r\n)\r\nprint(format_json(post_info))\r\n```\r\n\r\n\u53d1\u5e16\u53c2\u6570\u8bf4\u660e\r\n\r\n| \u5b57\u6bb5\u540d    | \u7c7b\u578b     | \u5fc5\u987b | \u63cf\u8ff0                  |\r\n|--------|--------|----|---------------------|\r\n| text   | string | \u662f  | \u6587\u672c\uff08\u6700\u591a\u4e0d\u8d85\u8fc7\u4e2a\u5b57\u7b26\uff0c\u5305\u62ec\u7a7a\u683c\u56de\u8f66\uff09 |\r\n| medias | list   | \u5426  | \u5a92\u4f53\u6587\u4ef6\u4e0a\u4f20\u540e\u7684\u5a92\u4f53id\uff08\u53ef\u6307\u5b9a\u591a\u4e2a\uff09 |              \r\n\r\n___\r\n\r\n\u56de\u5e16\u4f7f\u7528\u6848\u4f8b\uff08\u6307\u5b9a\u76ee\u6807\u5e16\u5b50\uff0c\u5bf9\u5176\u56de\u5e16\uff09\r\n\r\n```python\r\nfrom easy_spider_tool import format_json\r\nfrom easy_twitter_publisher import TwitterPost, get_headers\r\n\r\ntwitter_post = TwitterPost()\r\ntwitter_post.set_headers(get_headers(cookie))\r\ntwitter_post.set_proxy(proxy)\r\n\r\nreply_info = twitter_post.reply(\r\n    to_tweet_id='1690065356495421444',\r\n    text=\"\"\"Hi, I'm Han Xinkong\"\"\",\r\n    # medias=[twitter_media.media_id]\r\n)\r\nprint(format_json(reply_info))\r\n```\r\n\r\n\u56de\u5e16\u53c2\u6570\u8bf4\u660e\r\n\r\n| \u5b57\u6bb5\u540d         | \u7c7b\u578b     | \u5fc5\u987b | \u63cf\u8ff0                                                                                     |\r\n|-------------|--------|----|----------------------------------------------------------------------------------------|\r\n| to_tweet_id | string | \u662f  | \u76ee\u6807\u5e16\u5b50id\uff08https://twitter.com/elonmusk/status/1690164670441586688 \u4e2d\u7684 1690164670441586688\uff09 |\r\n| text        | string | \u662f  | \u6587\u672c\uff08\u6700\u591a\u4e0d\u8d85\u8fc7\u4e2a\u5b57\u7b26\uff0c\u5305\u62ec\u7a7a\u683c\u56de\u8f66\uff09                                                                    |\r\n| medias      | list   | \u5426  | \u5a92\u4f53\u6587\u4ef6\u4e0a\u4f20\u540e\u7684\u5a92\u4f53id\uff08\u53ef\u6307\u5b9a\u591a\u4e2a\uff09                                                                    |              \r\n\r\n___\r\n\r\n## \u4f9d\u8d56\r\n\r\n\u5185\u7f6e\u4f9d\u8d56\r\n\r\n- `typing` Type Hints for Python.\r\n- `os` Type Hints for Python.\r\n- `imghdr` Type Hints for Python.\r\n- `mimetypes` Type Hints for Python.\r\n- `pathlib` Type Hints for Python.\r\n- `json` Type Hints for Python.\r\n\r\n\u7b2c\u4e09\u65b9\u4f9d\u8d56\r\n\r\n- `loguru` An XPath for JSON.\r\n- `urllib3` An XPath for JSON.\r\n- `requests` An XPath for JSON.\r\n- `requests_toolbelt` Python library used for parsing dates from natural language text.\r\n- `easy_spider_tool` Python library used for parsing dates from natural language text.\r\n\r\n_\u6ce8\uff1a\u4f9d\u8d56\u987a\u5e8f\u6392\u540d\u4e0d\u5206\u5148\u540e_\r\n\r\n## \u94fe\u63a5\r\n\r\nGithub\uff1ahttps://github.com/hanxinkong/easy-twitter-publisher\r\n\r\n\u5728\u7ebf\u6587\u6863\uff1ahttps://easy-twitter-publisher.xink.top\r\n\r\n## \u8d21\u732e\u8005\r\n\r\n## \u8bb8\u53ef\u8bc1\r\n\r\n\u8be5\u9879\u76ee\u6839\u636e **MIT** \u8bb8\u53ef\u6761\u6b3e\u83b7\u5f97\u8bb8\u53ef.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\u7b80\u6613\u3001\u597d\u7528\u7684\u63a8\u7279(Twitter)\u53d1\u5e16/\u56de\u5e16\u7a0b\u5e8f,\u652f\u6301\u56fe\u7247\uff0c\u89c6\u9891",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://easy-twitter-publisher.xink.top/"
    },
    "split_keywords": [
        "easy",
        "twitter",
        "publisher"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee9c6584cb0fe6551d850f0e91c82a512b7275e60c920db364e3efc92e37932d",
                "md5": "bc4a512d9455167b83aea9c2abb415eb",
                "sha256": "e6a2273df236ea5c81e61493eee26a7075f8abb396bff9a55f7680faadfc50b4"
            },
            "downloads": -1,
            "filename": "easy_twitter_publisher-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bc4a512d9455167b83aea9c2abb415eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6.8",
            "size": 11220,
            "upload_time": "2023-09-09T04:03:21",
            "upload_time_iso_8601": "2023-09-09T04:03:21.749401Z",
            "url": "https://files.pythonhosted.org/packages/ee/9c/6584cb0fe6551d850f0e91c82a512b7275e60c920db364e3efc92e37932d/easy_twitter_publisher-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1144961f9a2d8753118986f6d13a0106a044824fc3e3091cf84a67fb930b16e4",
                "md5": "678183d2d0cec36737f85d21a1523154",
                "sha256": "d8ee80c441c6552752bee30e47cf1a6cff13db6763207aee5fd6160db4bde450"
            },
            "downloads": -1,
            "filename": "easy_twitter_publisher-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "678183d2d0cec36737f85d21a1523154",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.8",
            "size": 8479,
            "upload_time": "2023-09-09T04:03:24",
            "upload_time_iso_8601": "2023-09-09T04:03:24.099460Z",
            "url": "https://files.pythonhosted.org/packages/11/44/961f9a2d8753118986f6d13a0106a044824fc3e3091cf84a67fb930b16e4/easy_twitter_publisher-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-09 04:03:24",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "easy-twitter-publisher"
}
        
Elapsed time: 0.14419s