美文网首页
python 简单爬虫(spider) 环境配置

python 简单爬虫(spider) 环境配置

作者: 雨后池上灬 | 来源:发表于2019-07-26 14:47 被阅读0次

1、安装Python3.7:

     注:安装完后,检查 python的两个环境变量:

          C:\Users\Administrator\AppData\Local\Programs\Python\Python37

          C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts

2、使用PIP安装Jupyter Notebook:

     #### 使用阿里云作为python包下载的镜像地址,可以提高下载速度。  

     2.1 进入用户目录

     2.2.创键 pip 文件夹

     2.3.创建文件名为 pip.ini 的配置文件(注:文件后缀为.ini)

     2.4.添加内容
###########################################

[global]

index-url=http://mirrors.aliyun.com/pypi/simple/

[install]

trusted-host=mirrors.aliyun.com

##########################################

    2.5.运行命令

     pip install jupyter

3、使用PIP安装selenium:

   pip install selenium

4、使用PIP安装BS4:

  pip install beautifulsoup4

5、使用PIP安装信赖项:

  pip install tinydb urllib3 xlsxwriter lxml

6、下载geckodriver:

     解压到firefox根目录,再将此目录添加到环境变量path:

    ( 没有这一步,运行firefox headless时,会报错)

7、启动 jupyter notebook:

    CMD窗口下输入:jupyter notebook

8、配置 Jupyter notebook:

     8.1 生成jupyter配置文件:

           jupyter notebook --generate-config

     8.2 修改配置文件:

           打开“.jupyter”文件夹下的配置文件 jupyter_notebook_config.py,找到   

           “c.NotebookApp.notebook_dir=……”,把路径改成自己的工作目录。

           配置文件修改完成后, 以后在jupyter notebook中写的代码等都会保存在自己创建的目录中。

相关文章

网友评论

      本文标题:python 简单爬虫(spider) 环境配置

      本文链接:https://www.haomeiwen.com/subject/prarrctx.html