ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2021-05-24 21:01:37  阅读:225  来源: 互联网

标签:为鹏 Python restricted python 化鲲 aliyun universe main com


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


标签:为鹏,Python,restricted,python,化鲲,aliyun,universe,main,com
来源: https://blog.51cto.com/u_15214399/2808085

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有