Skip to main content

miracleplus tools

Project description

python工具

这个项目的原因是,我们的hn项目和gpt项目都用到了浏览器的内容解析和百度翻译。这两个功能代码一样,但是如果要做优化修改,那就得同时在两个项目中进行。所以把这两个功能抽象出来,放到了这个项目中。这样,如果要修改,只需要修改这个项目中的代码就可以了。

之后可能还会有一些别的工具公共的工具需要使用。所以这个项目就是一个公共的工具项目。

目前已有的工具:

  • 浏览器内容解析
  • 百度翻译

使用

浏览器内容解析

from miracleplus_tools import HtmlLoader
documents = HtmlLoader([url], html=True, partial=True).call()
documents[0].page_content # => 返回html

百度翻译

from miracleplus_tools import Translator
Translator().call(['test'])
# => ['测验']

依赖

如果要是用内容解析功能,需要安装以下依赖:

  • selenium
  • beautifulsoup4
  • readability-lxml

如果要使用百度翻译/GPT 翻译

  • 设定环境变量:BAIDU_APP_ID 和 BAIDU_APP_KEY
  • 安装 requests langchain

修改代码

  • 配置twine上传验证
  touch ~/.pypirc
  vim ~/.pypirc
  输入以下内容:
  [pypi]
    username = __token__
    password = pypi-AgEIcHlwaS5vcmcCJGQxMjAzNTc2LWU3ODYtNDEwZC05MjkwLTNmZGY1NjNhZTYzMQACKlszLCIwN2NiMGZlZC1jYzVhLTQwMzgtOTQ3ZS1jOGViOGZkZjA1ODAiXQAABiBWQ3q_Fjbp5Qme-kxmRTdovpL0mBpMliLMugfQKNBA-Q
  • 修改代码
  • 修改pyproject.toml 的版本号
  • 打包代码:
  poetry build
  • 上传到pypi
  twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

miracleplus_tools-0.0.5.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

miracleplus_tools-0.0.5-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file miracleplus_tools-0.0.5.tar.gz.

File metadata

  • Download URL: miracleplus_tools-0.0.5.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for miracleplus_tools-0.0.5.tar.gz
Algorithm Hash digest
SHA256 bdd5e9e5b852636e18e6a3490b67e20a6ee29c55743b0cf0ce83eb291bd7cbcd
MD5 89ed4bd6e2286d1d0ef5010d941ad42b
BLAKE2b-256 c4b2a2710e38d1bf4a2c044ccbee83041e3bf324e9b3df14003b5e9d9454172f

See more details on using hashes here.

File details

Details for the file miracleplus_tools-0.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for miracleplus_tools-0.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1eb2fd60902426a28574daa52605573e945b977082df3ceabb27140a276c64ef
MD5 5c9f3cd9f56af1fc141c933649703571
BLAKE2b-256 6846d06d025589f058ef8ac3590cd1e7442174c6c893a7577052012796c04dfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page