Scrapy-splash如何简单高效地应用于爬虫项目?

2026-04-20 11:462阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计308个文字,预计阅读时间需要2分钟。

Scrapy-splash如何简单高效地应用于爬虫项目?

`scrapy_splash` 是 Scrapy 的一个组件,用于加载基于 Splash 的 JavaScript 数据。Splash 是一个轻量级浏览器服务,实现 HTTP API 的浏览器,用 Python 和 Lua 语言实现,基于 Twisted。

1.scrapy_splash是scrapy的一个组件

scrapy_splash加载js数据基于Splash来实现的

Splash是一个Javascrapy渲染服务,它是一个实现HTTP API的轻量级浏览器,Splash是用Python和Lua语言实现的,基于Twisted和QT等模块构建

使用scrapy-splash最终拿到的response相当于是在浏览器全部渲染完成以后的网页源代码

2.scrapy_splash的作用

scrpay_splash能够模拟浏览器加载js,并返回js运行后的数据

3.scrapy_splash的环境安装

3.1 使用splash的docker镜像

docker info 查看docker信息

docker images 查看所有镜像

docker pull scrapinghub/splash 安装scrapinghub/splash

docker run -p 8050:8050 scrapinghub/splash & 指定8050端口运行

3.2.pip install scrapy-splash

3.3.scrapy 配置:

SPLASH_URL = 'localhost:8050' DOWNLOADER_MIDDLEWARES = { 'scrapy_splash.SplashCookiesMiddleware': 723, 'scrapy_splash.SplashMiddleware': 725, 'scrapy.downloadermiddlewares.www.biqugedu.com/0_25/'] custom_settings = { 'LOG_FILE': os.path.join(LOG_DIR, '%s_%s.log' % (name, datetime.date.today().strftime('%Y-%m-%d'))), 'LOG_LEVEL': 'INFO', 'CONCURRENT_REQUESTS': 8, 'AUTOTHROTTLE_ENABLED': True, 'AUTOTHROTTLE_TARGET_CONCURRENCY': 8, 'SPLASH_URL': 'localhost:8050', 'DOWNLOADER_MIDDLEWARES': { 'scrapy_splash.SplashCookiesMiddleware': 723, 'scrapy_splash.SplashMiddleware': 725, 'scrapy.downloadermiddlewares.www.biqugedu.com/files/article/image/0/25/25s.jpg'))

scrapy-splash接收到js请求:

到此这篇关于scrapy-splash简单使用详解的文章就介绍到这了,更多相关scrapy-splash 使用内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!

Scrapy-splash如何简单高效地应用于爬虫项目?

本文共计308个文字,预计阅读时间需要2分钟。

Scrapy-splash如何简单高效地应用于爬虫项目?

`scrapy_splash` 是 Scrapy 的一个组件,用于加载基于 Splash 的 JavaScript 数据。Splash 是一个轻量级浏览器服务,实现 HTTP API 的浏览器,用 Python 和 Lua 语言实现,基于 Twisted。

1.scrapy_splash是scrapy的一个组件

scrapy_splash加载js数据基于Splash来实现的

Splash是一个Javascrapy渲染服务,它是一个实现HTTP API的轻量级浏览器,Splash是用Python和Lua语言实现的,基于Twisted和QT等模块构建

使用scrapy-splash最终拿到的response相当于是在浏览器全部渲染完成以后的网页源代码

2.scrapy_splash的作用

scrpay_splash能够模拟浏览器加载js,并返回js运行后的数据

3.scrapy_splash的环境安装

3.1 使用splash的docker镜像

docker info 查看docker信息

docker images 查看所有镜像

docker pull scrapinghub/splash 安装scrapinghub/splash

docker run -p 8050:8050 scrapinghub/splash & 指定8050端口运行

3.2.pip install scrapy-splash

3.3.scrapy 配置:

SPLASH_URL = 'localhost:8050' DOWNLOADER_MIDDLEWARES = { 'scrapy_splash.SplashCookiesMiddleware': 723, 'scrapy_splash.SplashMiddleware': 725, 'scrapy.downloadermiddlewares.www.biqugedu.com/0_25/'] custom_settings = { 'LOG_FILE': os.path.join(LOG_DIR, '%s_%s.log' % (name, datetime.date.today().strftime('%Y-%m-%d'))), 'LOG_LEVEL': 'INFO', 'CONCURRENT_REQUESTS': 8, 'AUTOTHROTTLE_ENABLED': True, 'AUTOTHROTTLE_TARGET_CONCURRENCY': 8, 'SPLASH_URL': 'localhost:8050', 'DOWNLOADER_MIDDLEWARES': { 'scrapy_splash.SplashCookiesMiddleware': 723, 'scrapy_splash.SplashMiddleware': 725, 'scrapy.downloadermiddlewares.www.biqugedu.com/files/article/image/0/25/25s.jpg'))

scrapy-splash接收到js请求:

到此这篇关于scrapy-splash简单使用详解的文章就介绍到这了,更多相关scrapy-splash 使用内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!

Scrapy-splash如何简单高效地应用于爬虫项目?