- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试抓取一个网站,但需要在所有页面中使用启动画面,因为它们的内容是动态创建的。现在它只呈现第一页,而不是内容页或分页页。
代码如下:
import scrapy
from scrapy_splash import SplashRequest
import scrapy_splash
class ShutSpider(scrapy.Spider):
name = 'Shut'
def start_requests(self):
yield SplashRequest(url='ROOTURL',callback=self.parse)
def parse(self, response):
# follow links to author pages
content=response.xpath('//*[@id="iconQuesBar"]/a[4]/@href').extract()
for href in content:
yield response.follow(href.replace('?id=', ''), self.parse_QNA)
if content == []:
return
# follow pagination links
for href in response.xpath('//*[@id="body-div"]/table/tbody/tr[2]/td[3]/center/form/span/a/@href').extract():
yield response.follow(href, self.parse)
def parse_QNA(self, response):
yield {
'url': response.url,
'title': response.xpath('//h1[@class = "head"]/text()').extract()
我试过所有我能想到的方法,但没有用。我现在能想到的唯一解决方案是使用渲染 API 将链接发送到内容页面和分页,但我认为这是非常糟糕的编码,必须有另一种方法。
谢谢你的帮助。
最佳答案
代替 response.follow()
,明确地为后续页面生成新的 SplashRequest
。此外,在这种情况下,您还必须使用 response.urljoin()
。这是修改后的代码:
import scrapy
from scrapy_splash import SplashRequest
import scrapy_splash
class ShutSpider(scrapy.Spider):
name = 'Shut'
def start_requests(self):
yield SplashRequest(url='ROOTURL',callback=self.parse)
def parse(self, response):
# follow links to author pages
content = response.xpath('//*[@id="iconQuesBar"]/a[4]/@href').extract()
for href in content:
yield SplashRequest(response.urljoin(href.replace('?id=', '')), self.parse_QNA)
if content == []:
return
# follow pagination links
for href in response.xpath('//*[@id="body-div"]/table/tbody/tr[2]/td[3]/center/form/span/a/@href').extract():
yield SplashRequest(response.urljoin(href), self.parse)
def parse_QNA(self, response):
yield {
'url': response.url,
'title': response.xpath('//h1[@class = "head"]/text()').extract()
关于javascript - scrapy-splash 渲染多于第一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47831446/
正在构建一个使用一些 Azure 服务和 Scrapy-Splash 的 python Scrapy 应用程序。我尝试在本地 Windows 计算机中使用 scrapinghub/splash:lat
Unhandled promise rejection: Error: No native splash screen registered for given view controller. Ca
我使用这个 link 安装了 Splash .按照所有步骤进行安装,但 Splash 不起作用。 我的settings.py 文件: BOT_NAME = 'Teste' SPIDER_MODULES
我首先使用以下命令在 docker 上运行splash: docker run -p 8050:8050 scrapinghub/splash 当我转到端口 8050 并尝试渲染时: http://w
我使用了来自 repo 的完全相同的代码: https://github.com/pcess/tutorials/tree/master/SplashPermissions repo 中的独立应用程序
我有一个初始图像,它会在页面加载时随我的软件一起加载。 在窗口的当前大小(1024 像素)下,图像以居中方式加载,但是当窗口开始最大化时,它太靠左了。 这是我的CSS: #splash { wid
我有一个应用程序需要在启动前或在后台闲置一段时间后获取一些远程配置文件。我使用加载器 View Controller 来完成这项工作,同时显示带有加载指示器的初始屏幕。 显示加载程序的最佳方式是什么(
我正在尝试抓取 Google Scholar search results并获取与搜索匹配的每个结果的所有 BiBTeX 格式。现在我有一个带有 Splash 的 Scrapy 爬虫。我有一个 lua
我正在尝试将 scrapy 与启动和旋转代理一起使用。这是我的 settings.py: ROBOTSTXT_OBEY = False BOT_NAME = 'mybot' SPIDER_MODULE
我正在使用 FFMPEG 制作包含单个单色 JPG 图像的视频: ffmpeg -y -loop 1 -framerate 30 -t 5 -i SplashBW.jpg Splash.mp4 生成的
我正在尝试使用 fbi 为 Raspbian Stretch 提供启动画面。根据一些教程,我在这里找到了我的情况: /etc/systemd/system/splashscreen.service [
我正在使用Scrapy + Splash来爬网网页,并尝试从google广告横幅和其他广告中提取数据,但是我很难弄清楚要遵循xpath的方式。 我正在使用Scrpay-Splash API渲染页面,以
我已经成功使用此链接通过Tor运行Scrapy:http://pkmishra.github.io/blog/2013/03/18/how-to-run-scrapy-with-TOR-and-mul
我正在尝试抓取一个网站,但需要在所有页面中使用启动画面,因为它们的内容是动态创建的。现在它只呈现第一页,而不是内容页或分页页。 代码如下: import scrapy from scrapy_spla
我想在 Splash 随着时间结束时更改 viewController;我有这个: //Implementación de los métodos: - (void) cargaImagenes{
对于预先知道其个人资料 url 的几个 Disqus 用户中的每一个,我想抓取他们的姓名和他们的关注者的用户名。我正在使用 scrapy 和 splash 这样做。但是,当我解析响应时,它似乎总是在抓
我想做什么 在 avito.ru(俄罗斯房地产网站)上,某人的电话在您点击它之前是隐藏的。我想用Scrapy+Splash收集手机。 示例网址:https://www.avito.ru/moskva/
我正在尝试通过 Python 脚本调用 Splash 来呈现和抓取交互式网站,基本上遵循此 tutorial : import scrapy from scrapy_splash import Spl
我设法使用 scrapy+splash 连接到网站(感谢 this thread )。 我知道我已登录,因为我可以显示您登录后可用的一些元素。但是,当我尝试使用另一个 SplashRequest 访问
当我运行 cordova-splash 命令时出现此错误。获取未处理的错误事件 > > $ cordova-splash > > Checkin
我是一名优秀的程序员,十分优秀!