使用/进口美丽的汤4,无需安装 [英] Using/importing Beautiful Soup 4 without installation

查看:202
本文介绍了使用/进口美丽的汤4,无需安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着美丽的汤文件说:

如果一切都失败了,对美丽的汤许可,您可以与打包应用程序的整个库。您也可以下载压缩包,复制其BS4目录到应用程序的codeBase类,并用美丽的汤,不安装它。

If all else fails, the license for Beautiful Soup allows you to package the entire library with your application. You can download the tarball, copy its bs4 directory into your application’s codebase, and use Beautiful Soup without installing it at all.

这正是我想要的,我做了什么......最多我的code。使用它的地步。我不知道如何导入美丽的汤4.不同于V3,没有独立的 BeautifulSoup.py ,仅仅是 BS4 与一群Python脚本的目录。有没有人对如何当你有源$ C ​​$ C在项目中使用美丽的汤4个例子吗?

This is exactly what I want, and what I've done... up to the point of using it in my code. I don't know how to import Beautiful Soup 4. Unlike v3, there's no standalone BeautifulSoup.py, just that bs4 directory with a bunch of python scripts. Does anyone have an example of how to use Beautiful Soup 4 when you have the source code in your project?

推荐答案

这是一堆Python脚本被称为的 Python包;应该有一个 __ __初始化。PY 文件中的某个地方。它们共同形成一个连贯的整体,一个命名空间模块集。

That 'bunch of python scripts' is called a python package; there should be a __init__.py file in there somewhere. Together they form a coherent whole, a namespaced set of modules.

您可以直接导入由 BS4的 BeautifulSoup 包:

You can just import the BeautifulSoup class from the bs4 package:

from bs4 import BeautifulSoup

有关更多信息,请参阅的文档。

See the documentation for more info.

这篇关于使用/进口美丽的汤4,无需安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆