10 2017 档案
摘要:http://blog.csdn.net/dfhgshgdf/article/details/77512026
阅读全文
摘要:参考:http://blog.csdn.net/dawnranger/article/details/50037703 Selector 有一个 .re() 方法,用来通过正则表达式来提取数据。 不同于使用 .xpath() 或者 .css()方法, .re() 方法返回unicode字符串的列表,
阅读全文
摘要:参考:http://cuiqingcai.com/968.html http://cuiqingcai.com/977.html
阅读全文
摘要:参考博客:http://cuiqingcai.com/990.html 与用户交互
阅读全文
摘要:参考:http://www.jianshu.com/p/9d408e21dc3a http://www.cnblogs.com/luxiaojun/p/6144748.html 豆瓣应该是ip被封了。
阅读全文
摘要:# -*- coding:utf-8 -*- from selenium import webdriver from selenium.webdriver.common.keys import Keys import time print 1 # 创建一个无界面的对象 driver = webdriver.PhantomJS() driver.get("https://www.douba...
阅读全文
摘要:安装方式 $ pip install requests 基本GET请求(headers参数 和 parmas参数) 1.最基本的GET请求可以直接用get方法 response = requests.get("http://www.baidu.com/") # 也可以这么写 response = r
阅读全文
摘要:1.有些网页内容使用AJAX加载,AJAX一般返回的是JSON,直接对AJAX地址进行post或get,就返回JSON数据了。 2.用抓包工具分析https://movie.douban.com/j/chart/top_list?type=11&interval_id=100%3A90&action
阅读全文
摘要:1.发现在翻译时地址没有变,那是POST请求。 2.通过fidder抓包工具抓取url 3.对data分析,发现每次salt和sign都在变化。 4.查看源码,先用站长工具http://tool.chinaz.com/Tools/jsformat.aspx格式化,用sublines打开搜索到关键字s
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 import urllib, urllib2 3 import re 4 import sys 5 6 class Cuzz(): 7 """这是一个类""" 8 def __init__(self, url, header, start_page, end_page): 9 self.u...
阅读全文
摘要:urlopen 上面代码就是打开百度主页的“查看源代码”的内容,还是比较简单的。 Request 在上个例子里,urlopen()的参数就是一个url地址; 但是如果需要执行更复杂的操作,比如增加HTTP报头,必须创建一个 Request 实例来作为urlopen()的参数;而需要访问的url地址则
阅读全文
摘要:1 # -*- coding:utf-8 -*- 2 import urlparse 3 import urllib2 4 from bs4 import BeautifulSoup 5 6 url = "http://www.baidu.com" 7 8 urls = [url] # stack of urls to scrape 9 visited =...
阅读全文
摘要:1.代码如下: doubanmoive.py items.py 2.在管道文件中更改储存位置 3.新建中间件 middlewares.py 进行反反爬虫 4.setting的设置
阅读全文
摘要:1.用 scrapy 新建一个 sun0769 项目 scrapy startproject sun0769 2.在 items.py 中确定要爬去的内容 3.快速创建 CrawlSpider模板 scrapy genspider -t crawl dongguan wz.sun0769.com 注
阅读全文
摘要:1.用 scrapy 新建一个 tencent 项目 2.在 items.py 中确定要爬去的内容 3.快速创建 CrawlSpider模板 scrapy genspider -t crawl tencent_spider tencent.com 注意 此时中的名称不能与项目名相同 4.打开tenc
阅读全文
摘要:编程语言:Python2.7 1.在图灵机器人官网(http://www.tuling123.com)注册账号, 创建机器人, 如果只是学习的话,可以使用2免费版 , 一个账号最多可以创建5个机器人 , 一个机器人日调用接口数5000次 2.安装 itchat 和 pillow : sudo pip
阅读全文
摘要:1.用 scrapy 新建一个 tencent 项目 2.在 items.py 中确定要爬去的内容 1 # -*- coding: utf-8 -*- 2 3 # Define here the models for your scraped items 4 # 5 # See documentat
阅读全文
摘要:1.进入setting中把ITEM_piplines文件注销去掉 2.在piplines中写好代码 3.注意 在主文件中不用return, 用yield.
阅读全文
摘要:1.打开pycharm, 点击File>Open找到mySpider项目导入 . 2.打开File>Settings>Project 点击Project Interpreter 右边有个Scrapy, 选中确定. 3.在spiders文件下新建一个启动文件,我命名为start.py 4.选择conf
阅读全文

浙公网安备 33010602011771号