版权声明:本文为博主原创文章,随便转载,但是请注明出处。 https://blog.csdn.net/sbdx/article/details/78268211
前言
手上有个项目,采集国外物流信息,本来想用PHP,后来想想还是用时下热门的python跑采集试试吧
准备
安装Python v2.7.14
https://www.python.org/downloads/windows/
装好后修改pip源
在%USERPROFILE%目录里创建pip文件夹,在这个文件夹里新建pip.ini文件,内容如下
[global]
index-url=https://pypi.douban.com/simple
[list]
format=columns
这样就是使用国内豆瓣源,然后就可以愉快的安装插件了
PIP 常用采集库
pip install scrapy requests beautifulsoup4
MySQL-Python
https://pypi.python.org/pypi/MySQL-python
自动更新包脚本
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
尾声
requests抓数据好方便啊,比urllib1、2高级100倍
Requests中文文档 http://docs.python-requests.org/zh_CN/latest/user/install.html
To be continue…….