写这篇文章,不仅是为了汇总安装Scrapy的常见安装问题,还自己独立解决问题的能力。从一开始报VSC++版本的错误,到后来在CentOS运行pipinstalllxml很慢(CentOS7是一台虚拟机)。这是一种常见的安装lxml的异常情况:电脑环境:win1064位python环境:python2.7版本64位系统目标..
前面我们介绍了 BeautifulSoup 的用法,这个已经是非常强大的库了,不过还有一些比较流行的解析库,例如 lxml,使用的是 Xpath 语法,同样是效率比较高的解析方法。如果大家对 BeautifulSoup 使用不太习惯的话,可以尝试下 Xpath。 参考文档: lxml python ...
分类:
编程语言 时间:
2017-11-19 23:43:22
阅读次数:
488
from urllib.request import Request, ProxyHandler from urllib.request import build_opener from bs4 import BeautifulSoup import MySQLdb; import redis fr... ...
分类:
编程语言 时间:
2017-11-16 20:50:56
阅读次数:
142
1.安装Python 安装完了记得配置环境,将python目录和python目录下的Scripts目录添加到系统环境变量的Path里。在cmd中输入python如果出现版本信息说明配置完毕 2.安装lxml lxml是一种使用 Python 编写的库,可以迅速、灵活地处理 XML。网址https:/ ...
分类:
其他好文 时间:
2017-11-15 00:28:18
阅读次数:
209
# 爬豆瓣需要用cookie# 需要注意隐藏的参数,即input 里面的默认的一些参数# 需要自己注册一个账户密码import urllib.requestimport http.cookiejarfrom lxml import etreeimport spiderimagehead= { 'Co ...
分类:
编程语言 时间:
2017-11-13 22:59:13
阅读次数:
217
import urllib.request import http.cookiejar from lxml import etree head = { 'Connection': 'Keep-Alive', 'Accept': 'text/html, application/xhtml+xml, *... ...
分类:
其他好文 时间:
2017-11-11 13:20:37
阅读次数:
171
#通过登录去爬虫 #首先要有用户名和密码 import urllib.request import http.cookiejar from lxml import etree head = { 'Connection': 'Keep-Alive', 'Accept': 'text/html, app... ...
分类:
其他好文 时间:
2017-11-11 13:11:17
阅读次数:
150
import requestsimport jsonfrom retrying import retryfrom lxml import etreefrom queue import Queueimport threading class QiuShi: def __init__(self): # ...
分类:
编程语言 时间:
2017-11-10 23:12:27
阅读次数:
330
如果学会了python的基本语法,我认为入门爬虫是很容易的。 我写的第一个爬虫大概只需要10分钟,自学的 scrapyd , 看官方文档花了20分钟,因为我英文不是很好,很多单词需要搜索一下。 (scrapy 并不是入门必须的) 再接触到了 requests , lxml ,配合基本库 urllib ...
分类:
其他好文 时间:
2017-11-09 15:05:07
阅读次数:
160
#-*-coding:utf-8 -*- import urllib import re import json import urllib2 from lxml import etree import requests import time from Queue import Queue fro... ...
分类:
编程语言 时间:
2017-11-06 20:14:23
阅读次数:
231