Python 采集相关设定

来源:互联网 发布:战舰世界哈巴罗夫数据 编辑:程序博客网 时间:2024/06/10 17:34

前言

手上有个项目,采集国外物流信息,本来想用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 pipfrom subprocess import callfor 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…….