scrapy 登录后 抓取怎么设置抓取的网站发布时间超过就停止程序

Scrapy抓取网页相关问题解决以及注意事项总结 - CSDN博客
Scrapy抓取网页相关问题解决以及注意事项总结
1、urllib2是python自带的模块,在python3.x中被改为urllib.request,如&span&style=&font-size:12&&url&=&&/album/all?order=time&style=pop&&
html&=&urllib.request.urlopen(url).read()&&/span&&
Python3中使用&urllib.request解决
2、can't use a string pattern on a bytes-like object
& 3.0现在的参数更改了,现在读取的是bytes-like的,但参数要求是chart-like的,故定义pattern的时候在前面加一个小b,表示要操作的对象是bytes类型就可以了,如& url&=&&/album/all?order=time&style=pop&&html&=&urllib.request.urlopen(url).read()
uri&=&re.findall(b'/song/d+',html,re.M) &
s.encode(encoding) -& bytes
b.decode(encoding) -& str
bytes 就是一堆字节,str 是字符串;你把字符串按某种编码编码之后就成了一堆字节,正确地解码后就成了字符串。
# apps.append(apk.split(&:&)[-1].split(&=&)[0])报错:TypeError: 'str' does not support the buffer interface
按照下面做一个转换,就fix了
s=apk.decode(&GBK&).split(&:&)[-1].split(&=&)[0]
apps.append(s)
&out = shell(&dumpsys window w | %s \/ | %s name=& %(find_util, find_util)).stdout.read()
return pattern.findall(out)[0]
报错:can't use a string pattern on a bytes-like object
按照下面做一个转换,就fix了
&out = shell(&dumpsys window w | %s \/ | %s name=& %(find_util,find_util)).stdout.read().decode(&GBK&)
text = urllib.request.urlopen(url).read().decode(&GBK&)&& #后面加上.decode(&GBK&) 解决
3.使用python中html.unescape()方法就可以输出html中的实体字符
&#加上十进制码,Unicode十进制码转换为中文的显示方法。
Python3.5 Unicode十进制码转换为中文解决方法如下:
#!/usr/bin/env python
# encoding: utf-8
出& 关①&& 徐兰
凭山俯海古边州, 旆②影风翻见戍楼。
马后桃花马前雪,出关争得不回头?
[注]①关,指居庸关。②旆(pèi),旌旗。
import html
string = '[注]&#9312关,指居庸关。&#9313旆(pèi),旌旗。'
print(html.unescape(string))&&& #[注]①关,指居庸关。②旆(pèi),旌旗。
如果Python3中显示 no have html module 则需要pip install html 安装html模块
相关参考资料:
/python_decode_html_entity_and_convert_between_name_entity_and_code_point_entity/
Python3.3解决方法:http://bbs.csdn.net/topics/
Java实现的转换方法:http://bbs.csdn.net/topics/
其他Unicode转中文解决方法:http://blog.csdn.net/shanliangliuxing/article/details/8638371
4.Scrapy爬取相对链接和绝对链接问题:示例中抓取的url是相对链接,在第7行中用urljoin转换为完整的链接。
class StackOverflowSpider(scrapy.Spider):
name = 'stackoverflow'
start_urls = ['/questions?sort=votes']
def parse(self, response):
&&& for href in response.css('.question-summary h3 a::attr(href)'):
&&&&&&& full_url = response.urljoin(href.extract())
&&&&&&& yield scrapy.Request(full_url, callback=self.parse_question)
def parse_question(self, response):
&&& yield {
&&&&&&& 'title': response.css('h1 a::text').extract()[0],
&&&&&&& 'votes': response.css('.question .vote-count-post::text').extract()[0],
&&&&&&& 'body': response.css('.question .post-text').extract()[0],
&&&&&&& 'tags': response.css('.question .post-tag::text').extract(),
&&&&&&& 'link': response.url,
5.python 中列表、元组、字符串相互之间的转换问题
& Python中有三个内建函数:列表,元组和字符串,他们之间的互相转换使用三个函数,str(),tuple()和list(),具体示例如下所示:
&&& s = &xxxxx&
&&& list(s)
['x', 'x', 'x', 'x', 'x']
&&& tuple(s)
('x', 'x', 'x', 'x', 'x')
&&& tuple(list(s))
('x', 'x', 'x', 'x', 'x')
&&& list(tuple(s))
['x', 'x', 'x', 'x', 'x']
列表和元组转换为字符串则必须依靠join函数
&&& &&.join(tuple(s))
&&& &&.join(list(s))
&&& str(tuple(s))
&('x', 'x', 'x', 'x', 'x')&
6.Scrapy中用cookie模拟登陆新浪微博:
http://blog.csdn.net/gloria2799/article/details/
抓取天猫价格数据加上headers方法:http://blog.csdn.net/xu/article/details/
发送带cookie请求的方法:
import sys
from scrapy.spider import Spider
from scrapy.selector import Selector
from scrapy.http.request import Request
class InfoqSpider(Spider):
&&& name = &techbrood&
&&& allowed_domains = [&&]
&&& start_urls = [
&&&&&&& &&,
&&& def start_requests(self):
&&&&&&& for url in self.start_urls:&&&&&& &
&&&&&&&&&&& yield Request(url, cookies={'': 'true'})
7.分别用python2和python3伪装浏览器爬取网页内容
python网页抓取功能非常强大,使用urllib或者urllib2可以很轻松的抓取网页内容。但是很多时候我们要注意,可能很多网站都设置了防采集功能,不是那么轻松就能抓取到想要的内容。
python2和python3中都是如何来模拟浏览器来跳过屏蔽进行抓取的:
最基础的抓取:
#! /usr/bin/env python
# -*- coding=utf-8 -*-
# @Author pythontab
import urllib.request
html = urllib.request.urlopen(url).read()
print(html)
但是...有些网站不能抓取,进行了防采集设置,所以我们要变换一下方法
python2中(最新稳定版本python2.7)
#! /usr/bin/env python
# -*- coding=utf-8 -*-
import urllib2
req_header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
&&&&&&&&&&&& 'Accept':'text/q=0.9,*/*;q=0.8',
&&&&&&&&&&&& 'Accept-Charset':'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
&&&&&&&&&&&& 'Accept-Encoding':'gzip',
&&&&&&&&&&&& 'Connection':'close',
&&&&&&&&&&&& 'Referer':None #注意如果依然不能抓取的话,这里可以设置抓取网站的host
&&&&&&&&&&&& }
req_timeout = 5
req = urllib2.Request(url,None,req_header)
resp = urllib2.urlopen(req,None,req_timeout)
html = resp.read()
print(html)
python3中(最新稳定版本python3.3)
#! /usr/bin/env python
# -*- coding=utf-8 -*-
# @Author pythontab
import urllib.request
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
&&&&&&&&&&&& 'Accept':'text/q=0.9,*/*;q=0.8',
&&&&&&&&&&&& 'Accept-Charset':'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
&&&&&&&&&&&& 'Accept-Encoding':'gzip',
&&&&&&&&&&&& 'Connection':'close',
&&&&&&&&&&&& 'Referer':None #注意如果依然不能抓取,这里可以设置抓取网站的host
&&&&&&&&&&&& }
opener = urllib.request.build_opener()
opener.addheaders = [headers]
data = opener.open(url).read()
print(data)
8.匹配网页中指定位置的内容用括号括起来
pile('&td class=&val&&(.*?)&/td&&td class=&err&&&/td&&/tr&',re.M)
正则表达式完整用法
http://blog.csdn.net/wj/article/details/
本文已收录于以下专栏:
相关文章推荐
1、爬数据的时候,有时会遇到被该网站封IP等情况,response的状态码为403,那么这时候我们希望能够抛出
CloseSpider的异常。
2、但是如scrapy官网提到的,Scrapy默认的...
scrapy捕获爬取失败的url,返回任务状态
一、Scrapy Selectors简介
scrapy提供了本身提供了一种基于XPath和CSS 表达式的选择器,叫做Scrapy Selectors。
XPath是一种类似于层级选择的方式,与JQ...
通过 正则表达式 来获取一个网页中的所有的 URL链接,并下载这些 URL链接 的源代码使用的系统:Windows 10 64位
Python 语言版本:Python 2.7.10 V
使用的编程...
数据库设计时候没有充分考虑float、double类型,以及长度、十进位的含义
一开始将price字段的double类型,十进位设置为0,结果插入数据10.345,存在数据库都变成了10
十进位:...
/html/2014/pythonweb_.html
在爬取网站内容的时候,最常遇到的问题是:网站对IP有限制,会...
SVN清理显示乱码解决,sqlite3解压没有sqlite3.exe解决,SVN使用注意事项和问题解决
Windows7下安装SQL Server 2005注意事项及问题解决
一.安装失败时要卸载干净
   例如:
   SQL Server 2005
   SQL Server 200...
Windows7下安装SQL Server 2005注意事项及问题解决
一.安装失败时要卸载干净
   例如:
   SQL Server 2005
   SQL Server 200...
他的最新文章
讲师:王禹华
讲师:宋宝华
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)查看: 11222|回复: 9
手把手教你用python抓网页数据II(scrapy版)
精华主题学分
在线时间 小时
注册一亩三分地论坛,查看更多干货!
才可以下载或查看,没有帐号?
本帖最后由 victorsterling 于
22:18 编辑
The whole code in github: /victorsterling1/news_spider_scrapy
. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
前言:. Waral 鍗氬鏈夋洿澶氭枃绔,
之前超级玛丽大神写了一个利用python的urllib,urllib2的module去抓取网页数据(链接:)。这个帖子对我的帮助很大,也让我学习了很多知识。在此,我来好好膜拜一下超级玛丽大神。
作为转专业的学鶸,几个月前难得在北京混了一份技术岗的实习,工作学的算是能熟练一点的技能也就只有爬虫了。有难度的代码都搞得不太懂(没基础的zhazha求不鄙视)。在我码代码的过程中,地里的很多大神跟给我提供了很多的建议和帮助,在此感谢各位大神的帮助,同时在这里也分享一下我自己对于使用pyhton爬虫的一些心得。
就像超级玛丽之前说的,python和网页相关的几个module除了urllib,urllib2,httplib之外,还有mechanize和scrapy等。在这里,我使用的是scrapy去做网络爬虫。
-google 1point3acres
新手码的代码或许会有很多不尽人意的地方,希望各位大神多多指点,此帖子也仅仅是抛砖引玉,欢迎大家多多讨论。(大神们请尽情喷我代码写的烂吧)
. 1point 3acres 璁哄潧
步骤一:准备工作. 鍥磋鎴戜滑@1point 3 acres
首先要熟悉python的基本知识和使用方法,在这里推荐一门university of Michigan的:。本人今年年初跟的这门课,作为无基础的zhazha,我表示这门课学起来非常简单,毫不费力(估计也是因为这门课是基础中的基础),非常适合转专业的新手去学习。跟完之后对python的基本用法也大致有了了解。
(但是我实际工作中经常会有这种感慨:卧槽!这些代码都是啥?!!我TM真的学过Python吗??)
对python有了一定了解后,请安装好pyhton,设置好环境参量,并安装scrapy模块,教程如下:
其它需要的module在实际应用中,就见到需要什么就装什么,反正大多都可以在shell(cmd)中用pip install XX 就可以了。
步骤二:创建自己的项目. from: /bbs
scrapy安装完毕之后,就可以开始创建自己的项目了。比如:我们要去做一个从各大新闻网站抓取新闻内容的爬虫。我们就需要从网页中提取标题,正文,日期等信息。
首先,打开cmd,输入scrapy startproject news. Waral 鍗氬鏈夋洿澶氭枃绔,
就可以创建一个名字为news的项目。一般默认在我的文档目录下生成文件。文件目录如下:
news:.│&&scrapy.cfg
│└─news& &
& &│&&items.py& &
& &│&&pipelines.py& &
& &│&&settings.py& & . 1point 3acres 璁哄潧
& &│&&__init__.py& & . 鍥磋鎴戜滑@1point 3 acres
& &│ └─spiders& && && &&&. from: /bbs
& && && && & __init__.py
scrapy.cfg: 项目配置文件news/: 项目python模块, 呆会代码将从这里导入news/items.py: 项目items文件news/pipelines.py: 项目管道文件news/settings.py: 项目配置文件news/spiders: 放置spider的目录
步骤三:定义我们要提取的数据(item)
Items是将要装载抓取的数据的容器,它工作方式像python里面的字典,但它提供更多的保护,比如对未定义的字段填充以防止拼写错误。
我们使用IDLE(python自带编译器)打开items.py编辑代码,即可完成对item的定义。from scrapy.item import Item, Field
.1point3acres缃
class NewsItem(Item):
& & title = Field().
& & link = Field()
& & content = Field()
& & date = Field()复制代码步骤四:写爬虫(spider)
scrapy给提供的spider有很多种,如:BaseSpider,CrawlSpider,XMLFeedSpider,CSVFeedSpider等等。(关于spider的详细介绍和用法请看这里:)
其中最简单的是BaseSpider,最常用的是CrawlSpider,在这里我对这俩种进行介绍:. /bbs
进入spider目录,在这个目录下新建一个py文件,名字就是spider的name,然后进行编辑。
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
首先是BaseSpider (or Spider):
个人感觉比较适合爬一些有针对性的那种网页,比如:某一个新闻网站某子版块的新闻数据。
下面是一个爬搜狐新闻网站环保版块新闻的例子。# -*- coding: utf-8 -*-. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
import scrapy
from news.items import NewsItem
from scrapy.http import Request
import requests
. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
class SohuSpider(scrapy.Spider):
& & name = &sohu&
& & allowed_domains = [&&]
& & start_urls = (
& && && && && & '/hbdt/',
& && && && && & #'/gongyiyw/'
& && && && && & #'/salon/index.shtml'.鐣欏璁哄潧-涓浜-涓夊垎鍦
& && && && && & #'/focus/index.shtml'
& && && && && & #'/gongyicehua/'
& & def __init__(self): 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
& && &&&self.count = 33
& & def parse(self, response):
& && &&&try:
& && && && &lis = response.css('div[class=&f14list&]').xpath('ul').xpath('li')
& && && && &for li in lis:
& && && && && & item = EnvItem(). 鍥磋鎴戜滑@1point 3 acres
& && && && && & item['link'] = li.xpath('a/@href').extract()[0]
& && && && && & if not li.xpath('a/text()'):
& && && && && && && && &continue
& && && && && & item['title'] = li.xpath('a/text()').extract()[0]
& && && && && & link_info = item['link'].split(&/&).
& && && && && & link_info2 = link_info[-2] 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
& && && && && & item['date'] = link_info2[:4] + '-' + link_info2[4:6] + '-' + link_info2[6:].鏈枃鍘熷垱鑷1point3acres璁哄潧
& && && && && &
& && && && && & r = requests.get(item[&link&]).1point3acres缃
& && && && && & r.encoding=r.apparent_encoding
& && && && && & data = r.text
& && && && && & link_list = re.findall('&p&(.*?)&/p&' ,data). from: /bbs
& && && && && & item[&content&] = ''. From 1point 3acres bbs
& && && && && & if&&link_list:. 1point 3acres 璁哄潧
& && && && && && &&&item[&content&] = ''.join(link_list)
& && && && && & else :
& && && && && && &&&print 'NONE'
& && && && && & yield item
& && &&&except:
& && && && &pass
.1point3acres缃
& && &&&if self.count&0:
& && && && &url = &/hbdt/index_& + str(self.count) + &.shtml&.鐣欏璁哄潧-涓浜-涓夊垎鍦
& && && && &print url
& && && && &self.count -= 1
& && && && &yield Request(url, callback = self.parse)复制代码其次是CrawlSpider:
这个就更加粗暴一些,通rule规则去爬此网站域名下所有的网页,再根规则从中选择想要提取数据的网页进行数据提取,(简单粗暴,不过感觉大数据分析抓数据就该这么粗暴地大规模抓数据吧)
下面是一个爬地方性新闻网站的例子。#-*-coding:utf-8-*-
#Author: Victor
import re 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
import scrapy.鏈枃鍘熷垱鑷1point3acres璁哄潧
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import HtmlXPathSelector
from scrapy.http import Request
from scrapy.selector import HtmlXPathSelector.
import time
from news.items import NewsItem
class HongSpider(CrawlSpider):. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
& & name = 'hong'
& & allowed_domains = ['']
& & start_urls = [&/&]. 1point 3acres 璁哄潧
& & rules = (
& && &&&Rule(SgmlLinkExtractor(allow=(r'http://.*./[cC]/[0-9]+/[0-9]+/[0-9]+/[0-9]+.htm'), unique=True),callback='parse_item'),
& && &&&Rule(SgmlLinkExtractor(allow=(r'http://.*./[cC].*.*'), unique=True)),
. more info
& & def parse_item(self, response): 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
& && &&&try:. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
& && && && &hxs = HtmlXPathSelector(response)
& && && && &item = NewsItem(). Waral 鍗氬鏈夋洿澶氭枃绔,
& && && && &item['link'] = response.url
& && && && &item['title'] = hxs.select(&//head/title/text()&).extract()[0]
& && && && &time_raw = item['link'].split('/')
& && && && &item['date'] = time_raw[-4] + &-& + time_raw[-3] + &-& + time_raw[-2]
& && && && &item['content'] = ''
& && && && &content_list = hxs.select(&//div[@id='articlecontent']/p/text()&).extract(). 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
& && && && &if content_list ==[]: 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
& && && && && & content_list = hxs.select(&//div[@id='articlecontent']/P/text()&).extract()
& && && && &if content_list ==[]:
& && && && && & content_list = hxs.select(&//div[@id='articlecontent']/FONT/text()&).extract()
& && && && &if content_list ==[]:
& && && && && & content_list = hxs.select(&//div[@id='articlecontent']/text()&).extract()
& && && && &if content_list ==[]:
& && && && && & content_list = hxs.select(&//font[@id='zoom']/text()&).extract()
& && && && &if content_list ==[]:
& && && && && & content_list = hxs.select(&//div[@id='zoom']/text()&).extract()
& && && && &if content_list:
& && && && && & item['content'] = ''.join(content_list)
& && && && &else:
& && && && && & print 'None'.鏈枃鍘熷垱鑷1point3acres璁哄潧
& && && && &if item['content'] == '':. /bbs
& && && && && & item['content'] = &null&
& && && && &yield item. more info
& && && && &time.sleep(1)
& && &&&except:
& && && && &pass
& &&&复制代码步骤五:设置存储文件的方式和项目设置. Waral 鍗氬鏈夋洿澶氭枃绔,
先设置项目的setting:
打开之前的生成的settings.py,编译代码BOT_NAME = 'news'
SPIDER_MODULES = ['news.spiders']
NEWSPIDER_MODULE = 'news.spiders'
ITEM_PIPELINES = [
& & 'news.pipelines.NewsPipeline']
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/ Firefox/38.0'复制代码其实,前面那几行都已经自动生成好了,我们所需要做的仅仅只是设置一个user_agent而已。这个东西,自己去常用的浏览器找找看能不能看到吧。
. more info
虽然我觉得这东西并没有什么卵用······我之前忘记设置了也照样能爬。不过还是严谨一点比较好。
然后是对项目储存方式的设置:
打开之前生成的pipelines.py,进行编译import json
import codecs
from os import path. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
from scrapy import signals
class NewsPipeline(object):. more info
& & def __init__(self):
& && &&&self.file = codecs.open('raw_data.json', 'w',&utf-8&). /bbs
& & def process_item(self, item, spider):
& && &&&line = json.dumps(dict(item)) + &\n&
& && &&&self.file.write(line)
& && &&&return item复制代码将数据保存为json文件,方便之后转换成数据库文件。 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
当然,如果你想直接需要用,而不是看那些json文件里面看不懂的unicode编码的话,我下面介绍一种可以直接拿出来用的保存方式。import json. Waral 鍗氬鏈夋洿澶氭枃绔,
import codecs
from os import path
from scrapy import signals
. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
class NewsPipeline(object):
& & def __init__(self):
& && &&&self.file = codecs.open('raw_data.doc', 'w','utf-8')
& & def process_item(self, item, spider):& && &&&-google 1point3acres
& && &&&self.file.write(item['title']+&\n&)
& && &&&self.file.write(item['link']+&\n&)
& && &&&self.file.write(item['date']+&\n&)
& && &&&self.file.write(item['content']+&\n&). Waral 鍗氬鏈夋洿澶氭枃绔,
& && &&&return item
& && &&&file.close()
步骤六:万事俱备,让我们开始爬吧
在news文件夹下,按住shift右击,然后选择进入命令窗口,输入:
scrapy crawl hong& &&&#hong是我们其中一个spider的name.鐣欏璁哄潧-涓浜-涓夊垎鍦
就可以开始爬啦。
提取数据的文件将保存在当前目录下。.鏈枃鍘熷垱鑷1point3acres璁哄潧
欢迎各位大神多多指点我代码上的不足哈。大家多多讨论。
. Waral 鍗氬鏈夋洿澶氭枃绔,
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
<p id="rate_227" onmouseover="showTip(this)" tip="感谢分享!&大米 + 5 升
" class="mtn mbn">
<p id="rate_59" onmouseover="showTip(this)" tip="感谢分享!&大米 + 150 升
" class="mtn mbn">
<p id="rate_990" onmouseover="showTip(this)" tip="感谢分享!&大米 + 10 升
" class="mtn mbn">
<p id="rate_67" onmouseover="showTip(this)" tip="感谢分享!&大米 + 3 升
" class="mtn mbn">
<p id="rate_99" onmouseover="showTip(this)" tip="&大米 + 150 升
" class="mtn mbn">
<p id="rate_080" onmouseover="showTip(this)" tip="欢迎来介绍你知道的情况&大米 + 3 升
" class="mtn mbn">
<p id="rate_992" onmouseover="showTip(this)" tip="感谢分享!&大米 + 10 升
" class="mtn mbn">
<p id="rate_67" onmouseover="showTip(this)" tip="感谢分享!&大米 + 60 升
" class="mtn mbn">
<p id="rate_16" onmouseover="showTip(this)" tip="抬举了,写的很棒啊!!&大米 + 100 升
" class="mtn mbn">
<p id="rate_755" onmouseover="showTip(this)" tip="感谢分享!&大米 + 5 升
" class="mtn mbn">
<p id="rate_189" onmouseover="showTip(this)" tip="初学路过,先mark下,过完基础再仔细看~&大米 + 5 升
" class="mtn mbn">
<p id="rate_473" onmouseover="showTip(this)" tip="赞赞赞!&大米 + 150 升
" class="mtn mbn">
精华主题学分
高级农民, 积分 1614, 距离下一级还需 3386 积分
在线时间 小时
Python不熟但是感觉很有用啊,有空的时候follow介个练习~~谢谢楼主!!
精华主题学分
在线时间 小时
Python不熟但是感觉很有用啊,有空的时候follow介个练习~~谢谢楼主!!
好嘞,大家互相交流哈!
精华主题学分
在线时间 小时
Follow 楼主,我也学习
精华主题学分
在线时间 小时
谢谢LZ分享。还有一个BeautifulSoup也很好用。
精华主题学分
在线时间 小时
谢谢楼主分享,学习了!
精华主题学分
在线时间 小时
.1point3acres缃
谢谢LZ分享。还有一个BeautifulSoup也很好用。. Waral 鍗氬鏈夋洿澶氭枃绔,
最近用了一下beautifulsoup,感觉这个跟scrapy相比还是差很多啊,很难实现一些html节点的精准抓取,只是一些常用的,笼统的数据提取,感觉不是很有效力。还是说我自己的用的不地道??
精华主题学分
在线时间 小时
棒呆!!!!!
精华主题学分
在线时间 小时
强力马可马可马可!!!!!!!!!
精华主题学分
在线时间 小时
已把整体的code上传到github上,大家想要实践的话,可以直接下载下来试试看。
<form method="post" autocomplete="off" id="fastpostform" action="forum.php?mod=post&action=reply&fid=172&tid=136879&extra=&replysubmit=yes&infloat=yes&handlekey=fastpost"
onSubmit="
// TODO Howard 11/3/2015
var sbtn = $('fastpostsubmit');
sbtn.disabled =
sbtn.innerHTML = ' 回复发表中... ';
sbtn.setAttribute('background', sbtn.style.background);
sbtn.setAttribute('bordercolor', sbtn.style.borderColor);
sbtn.style.background = '#C7C7C7';
sbtn.style.borderColor = '#8B8B8B';
var form =
// --product--
var isValid = fastpostvalidate(form, null, 0);
if(!isValid) reoverBtn();
return isV
// --product--
// --testing--
//setTimeout(function() {
// var isValid = fastpostvalidate(form, null, 0);
// if(!isValid) reoverBtn();
//}, 2000);
// --testing--
您需要登录后才可以回帖
回帖并转播
回帖后跳转到最后一页
一亩三分地推荐 /5
地主Warald亲手做你的申请,针对你的背景和目标,考虑申请、学习、就业、移民等系列问题,制定申请策略。
“offer”指全额奖学金,免学费全免+每月工资,Berkeley, CMU, JHU, UIUC, Gatech, UMich, UCLA, Columbia,欢迎观赏。
电子工程、计算机、统计、金数金工、化工等, Stanford, Berkeley, CMU, Cornell, Yale, Columbia, Chicago, Duke, UPenn, UIUC, Brown, UMich, JHU等
有留学、申请、找工、职业规划上的难题?先上论坛提问!
论坛考古也帮不上忙,发帖得到的回答仍然不够?电话找Warald来解答!
WARALD新书上市啦:《你不知道的美国留学》清华大学出版社,各大电商发售
Powered by}

我要回帖

更多关于 scrapy递归抓取网页 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信