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-AgEIcHlwaS5vcmcCJGFmY2U1YTczLWUyYjUtNDM5ZS04YjNhLTViODFjNWM0ZTk0OAACKlszLCIwN2NiMGZlZC1jYzVhLTQwMzgtOTQ3ZS1jOGViOGZkZjA1ODAiXQAABiB4xdVeAuhZiwQxkWUuiykHrVLvWnMGHA9H_vP8lHjMFQ
  • 修改代码
  • 修改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.6.tar.gz (7.1 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.6-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for miracleplus_tools-0.0.6.tar.gz
Algorithm Hash digest
SHA256 3ac17883aa32437a8e345ec1c3b493d32432fdc20ffd2808402a263c2bac1908
MD5 f8a90ec707d14cdfbcc4f16840f18c45
BLAKE2b-256 d1b9e1f06a3150a504dccb01924be8a901b7f7aee58166089ad07195797e715a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for miracleplus_tools-0.0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d0472d7c34fe723cc186b3b6ee8b76715af4d84d0cc65db8cd6a647bf2c96258
MD5 55c122e13e0b92de6d127861eedd1900
BLAKE2b-256 cf34d5018a2f7c8e2034f4b9f5306823056bf05ccf7f2e002f0c28f05ec5948f

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