您的位置:首页技术文章
文章详情页

python - 用scrapy-splash爬取网站 为啥iframe下的内容没有被返回

【字号: 日期:2022-08-10 09:23:22浏览:52作者:猪猪

问题描述

用scrapy-splash爬取网站 为啥iframe下的内容没有被返回?

import scrapyfrom scrapy import Selectorclass Music163Spider(scrapy.Spider): name = 'music163' allowed_domains = ['music.163.com/#/discover/toplist'] start_urls = [’http://music.163.com/#/discover/toplist/’] def parse(self, response):print('parse:',response.text) def start_requests(self):for url in self.start_urls: yield scrapy.Request(url, self.parse, meta={’splash’: { ’endpoint’: ’render.html’, ’args’: {’wait’: 0.5, }} })

问题解答

回答1:

你需要在parse中获取iframe的url再次请求内容。

标签: Python 编程
相关文章: