• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
oooooolr
You can do anything but not everything. ——David Allen
博客园    首页    新随笔    联系   管理    订阅  订阅

dygod.net

# -*- coding: utf-8 -*-
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule


class DgSpider(CrawlSpider):
    name = 'dg'
    # allowed_domains = ['https://www.dygod.net']
    start_urls = ['https://www.dygod.net/html/gndy/dyzz/index.html']

    rules = (
        Rule(LinkExtractor(allow=r'https://www.dygod.net/html/gndy/dyzz/index_\d+.html')),
        Rule(LinkExtractor(allow=r'https://www.dygod.net/html/gndy/dyzz/\d+/\d+.html'), callback='parse_item', follow=True),
    )

    def parse_item(self, response):
        item = {}
        #item['domain_id'] = response.xpath('//input[@id="sid"]/@value').get()
        item['name'] = response.css('div[id*=Zoom] p:nth-child(3)::text').get()
        # item['time'] = response.xpath('//div[@id="description"]').get()
        return item

刚开始报错,因为 start_urls的https://www.dygod.net/html/gndy/dyzz/index.html最后多了一个/

后来继续报错,filter offline ....dygod.net,没搞清楚就直接把allowed_domains注释掉了就好了。。。,

但是扒下来的汉字都是\u25ce\u7247\u3000\u3000\u540d\u3000 Unicode模式

 

 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- focus on what you want to be
posted @ 2019-03-03 10:08  oooooolr  阅读(4227)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3