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

如果要使用百度翻译

  • 设定环境变量:BAIDU_APP_ID 和 BAIDU_APP_KEY

修改代码

  • 配置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.3.tar.gz (6.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.3-py2.py3-none-any.whl (7.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: miracleplus_tools-0.0.3.tar.gz
  • Upload date:
  • Size: 6.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.3.tar.gz
Algorithm Hash digest
SHA256 ce54728a1932cfc209bf891c697723d40ad842c8967360e3d3f6a20924b2b8e6
MD5 3f1f535a610eb9ad2353dbec1f16b502
BLAKE2b-256 7e31684e493dbd6b1c3c053131e9246386f2102c27f3d0354b42a29a94ebcccd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for miracleplus_tools-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0127963a8e0ec5f96f970f43e0e7ada6ab7104d16a7576347940402be49af7bf
MD5 f9a9df918492ee61c7e9837801e5877f
BLAKE2b-256 af52dcd7d876e0f7c05341e0edb0a5baaab5feca204f0118d2eb21f678df3dd8

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