通过Python使用BeautifulSoup库 [英] Using BeautifulSoup Library with Python

查看:108
本文介绍了通过Python使用BeautifulSoup库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习有关使用Python和Beautiful Soup库创建地图的教程.

I'm following a tutorial on creating a map using Python and the Beautiful Soup library.

我已经下载了漂亮的汤,该文件夹称为"beautifulsoup4-4.1.3".该文件夹的内容位于附件图像中.

I have downloaded beautiful soup and the folder is called "beautifulsoup4-4.1.3". The contents of this folder are in the attached image.

在教程中,我得到了以下代码,可用于导入我的数据和漂亮的汤:

During the tutorial I am given the following code to use to import my data and beautiful soup:

import csv
from BeautifulSoup import BeautifulSoup

问题是,在漂亮的汤文件夹中没有名为美丽汤"的文件.我还附加了我在终端中收到的错误消息.

Trouble is that there is no file called "beautiful soup" within the beautiful soup folder. I have also attached the error message I receive in the terminal.

在没有该名称的文件的情况下,我应该如何导入漂亮的汤?我尝试简单地将文件夹名称更改为美丽汤".我没想到那能行得通,而且我是对的-没来.

How should I import beautiful soup when there is no file with that name? I tried simply changing the folders name to "beautiful soup". I did not expect that to work and I was right - it did not.

有任何关于如何进行欢迎的建议吗?

Any advice on how to proceed welcome?

推荐答案

或者将bs4文件夹移动到脚本所在的目录中,或者通过easy_installpip安装模块.然后,您可以像这样导入它:

Either move the bs4 folder in the same directory as your script, or install the module via easy_install or pip. Then you can import it like this:

from bs4 import BeautifulSoup

这篇关于通过Python使用BeautifulSoup库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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