这篇文章将为大家详细讲解有关 Python 中怎么自动获取数据,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
公司主营业务:网站制作、成都做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联公司推出长丰免费做网站回馈大家。
首先打开我们的软件界面:

点击右上方的 Process:

其中 Name就是项目的名字,Location是保存的位置,Description 就是我们的对于项目的描述。
接下来让我们新建一个项目,进入工作界面:

简单介绍一下,最上方一栏是我们的工具栏,左边的区域是我们要创建项目的小组件,右边显示小组件的属性。
先从我们喜欢的 Hello World 开始吧。
从左边的 Activities 选取一个叫做 Sequence 的小组件,它叫做流程,我们所选取的小组件都要放在里面。
接着只要一直按住它就可以将它拖拽到中间区域,就是这样:

然后继续在 Activities 里搜索 Message box,它可以将我们的内容输出。

同样将他拖拽到中间区域,并且是在 sequence 里面,就像这样:

叹号表示有错误,我们在里面输入"Hello World",这样叹号就会消失。
注意:当我们输入的是常量时,必须用英文的引号,当是变量时候,就可以不用引号。
点击保存,运行一下,点击左上角的Run:

就会运行出现如下:

是不是有点好玩呢?
接下来我们再来用这个软件获取一下数据。
拿当当网来做例子,我们首先导航到这个网站,在 Activities 搜索一下 open Browser:

拖拽到中间区域:

出现了叹号,不要急,第一行我们输入当当必读书籍网址:
"http://search.dangdang.com/?key=%B1%D8%B6%C1&act=input"

如果点击了运行电脑就会自动打开 IE 浏览器并且打开当当网页面:

如果不想用 IE ,可以下载别的浏览器插件,如下所示:

获取数据我们不用一步一步操作拖拽,可以直接使用第一行的工具栏里面的 DataScraping,点击它:

点击 Next,然后用我们的鼠标点击书的名字:

接下来会出现:

继续点击 Next,然后点击另一本书的名字,会出现:

Column1 我们也可以修改为自己想修改的名称,继续点击 Next,我们就会看到抓取到的数据:

最下面的100那里可以选择我们要获取的最大行数,点击完成:

点击No,如果点击Yes是可以获取下一页的内容,这里我们不需要,返回软件,直接出现如下内容:

当然我们还可以将获取的数据保存到Excel里。
我们在 Activities 里面搜索 Excel Application Scope 拖拽到项目里面,在Do里面拖拽一个 write range:

在我们刚才获取数据的属性里面:

右下角有一个 Output ,这就是输出的数据的变量,将这个变量复制粘贴到 write range 的里面,并且在 Excel Application Scope 组件选取一个要保存的 Excel 文件,然后点击运行,这样我们就可以将数据保存到 Excel 里面了:

关于 Python 中怎么自动获取数据就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
网页名称:Python中怎么自动获取数据
文章起源:http://scpingwu.com/article/jcdeod.html