“化鲲为鹏,我有话说”如何用鲲鹏弹性云服务器部署《Python网络爬虫开发环境》
2021/5/24 22:27:44
本文主要是介绍“化鲲为鹏,我有话说”如何用鲲鹏弹性云服务器部署《Python网络爬虫开发环境》,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
python的网络爬虫功能是有目共睹的,我这边简单介绍下我所理解的,在鲲鹏服务器上布署网络爬虫实战开发环境的一个过程!
首先:需ECS有python环境基础(这论坛里有很多人发过相关的贴子,太家可以选择性的查看下),后面再一步步怎样安装依赖包!
环境好了后面的一些开发实战详解,完整案例演示,源码框架剖析等!
-----------------------------------------------------------------------------------------------------------------------------------
因所有的操作都是现学现卖,所以有兴趣可以等贴子完结后再仔细查看,本人先起个草稿先!请看官多担待些!
1、ECS操作系统和位数信息
规格 : 2vCPUs | 4GB | kc1.large.2
镜像 :Ubuntu 18.04 64bit with ARM
又省了一步,系统都自带了!Python 2和Python 3镜像都包含有呀!!!~~~~~~~~~~~~~~~~
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-htmlrequests-html 全新爬虫包来袭
全面支持解析JavaScript!
CSS 选择器 (jQuery风格,).
XPath 选择器, for the faint at heart.
自定义user-agent (就像一个真正的web浏览器).
自动追踪重定向.
连接池与cookie持久化.
令人欣喜的请求体验,魔法般的解析页面.
这篇关于“化鲲为鹏,我有话说”如何用鲲鹏弹性云服务器部署《Python网络爬虫开发环境》的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-27使用python 将ETH账户的资产打散
- 2024-09-26Python编程基础
- 2024-09-2610 种方法写出更好的 Python 代码
- 2024-09-25Python编程基础详解
- 2024-09-25Python编程入门教程
- 2024-09-25从零开始使用Python构建LLaMA 3
- 2024-09-23Python中理解和使用树形结构的简单教程
- 2024-09-23Python 编程基础入门
- 2024-09-18初探Python股票自动化交易:入门指南
- 2024-09-18Python量化入门:轻松掌握量化分析基础与实战