#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Created on 2018-03-02 23:14:26
# Project: huxiu
from pyspider.libs.base_handler import *
class Handler(BaseHandler):
crawl_config = {
}
@every(minutes=24 * 60)
def on_start(self):
self.crawl('https://www.huxiu.com/channel/105.html', callback=self.index_page,validate_cert=False)
@config(age=10 * 24 * 60 * 60)
def index_page(self, response):
for each in response.doc('.mod-b.mod-art.clearfix h2 > a').items():
self.crawl(each.attr.href, callback=self.detail_page,validate_cert=False,fetch_type='js')
@config(priority=2)
def detail_page(self, response):
return {
"url": response.url,
"title": response.doc('title').text()+' ',
"detail":response.doc('.article-content-wrap > p').text()
}
python 爬虫实战(三)使用pyspider爬取虎嗅新闻
原文作者:JonPia
原文地址: https://blog.csdn.net/xiawai/article/details/79527668
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
原文地址: https://blog.csdn.net/xiawai/article/details/79527668
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。