zoukankan      html  css  js  c++  java
  • “化鲲为鹏,我有话说”如何用鲲鹏弹性云服务器部署《Python网络爬虫开发环境》

    python的网络爬虫功能是有目共睹的,我这边简单介绍下我所理解的,在鲲鹏服务器上布署网络爬虫实战开发环境的一个过程!

    首先:需ECS有python环境基础(这论坛里有很多人发过相关的贴子,太家可以选择性的查看下),后面再一步步怎样安装依赖包!

    环境好了后面的一些开发实战详解,完整案例演示,源码框架剖析等!

    -----------------------------------------------------------------------------------------------------------------------------------

    因所有的操作都是现学现卖,所以有兴趣可以等贴子完结后再仔细查看,本人先起个草稿先!请看官多担待些!

    1、ECS操作系统和位数信息

    规格 : 2vCPUs | 4GB | kc1.large.2

    镜像 :Ubuntu 18.04 64bit with ARM

    image.png

    又省了一步,系统都自带了!Python 2和Python 3镜像都包含有呀!!!~~~~~~~~~~~~~~~~

    image.png

    2、安装依赖包、实战源码维护地址:https://github.com/zhangziliang04/requests-html/tree/master/example/Exam3.8

    安装依赖包前最好升级下pip,刚实际操作的时候碰到一大堆报错,仔细研究了下,发现不能这样操作,得先解决版本切换问题

    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
    update-alternatives --list python

    root身份,使用以下命令随时在列出的python替换版本中任意切换

    sudo su
    update-alternatives --config python

    输入“1”,就切换到2.7版本了,相反如果之前默认版本为2.7的输入“2”则切换到3.6版本了。

    python --version

    看到是你想要的版本了!~!

    解决完python切换问题,再重装下pip,装源的过程中,又碰到源下载不OK问题,又得更换源!汗,麻烦事真多呀

    到源目录下,清空,然后再把国内源添加进去

    cd /etc/apt
    ll
    >sources.list
    vim sources.list
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    apt-get update
    apt install python3-pip
    pip install -U pip   #针对2.7版本
    pip3 install -U pip  #针对3.6版本
    pip3 install requests-html

    image.png

    requests-html 全新爬虫包来袭

    全面支持解析JavaScript!

    CSS 选择器 (jQuery风格,).

    XPath 选择器, for the faint at heart.

    自定义user-agent (就像一个真正的web浏览器).

    自动追踪重定向.

    连接池与cookie持久化.

    令人欣喜的请求体验,魔法般的解析页面.

    image.pngimage.png

    作者:yxmos2019 

  • 相关阅读:
    python技巧
    tikz vfill vfil
    知之为知之,不知为不知
    newPost
    欢迎使用 WordPress 3.2.1 for SAE
    校正oracle,mysql,hive,postgresql,greenplum 记录数分析命令
    Hive 分区表&分区字段
    oracle 建表、主键、分区
    使用TortoiseSVN 客户端的一些问题
    jquery bankInput银行卡账号格式化
  • 原文地址:https://www.cnblogs.com/2020-zhy-jzoj/p/13165108.html
Copyright © 2011-2022 走看看