我可以在不使用 python 打开实际浏览器的情况下将 selenium 与 Scrapy 一起使用吗 [英] Can i use selenium with Scrapy without actual browser opening with python

查看:53
本文介绍了我可以在不使用 python 打开实际浏览器的情况下将 selenium 与 Scrapy 一起使用吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用scrapy和python做一些网络爬虫.我从互联网上找到了几个使用 selenium 和 scrapy 的代码示例.

I want to do some web crawling with scrapy and python. I have found few code examples from internet where they use selenium with scrapy.

我对 selenium 了解不多,但只知道它可以自动执行一些网络任务.和浏览器实际上打开并做一些事情.但我不想打开实际的浏览器,但我希望一切都从命令行发生.

I don't know much about selenium but only knows that it automates some web tasks. and browser actually opens and do stuff. but i don't want the actual browser to open but i want everything to happen from command line.

我可以在 selenium 和 scrapy 中做到这一点

Can i do that in selenium and scrapy

推荐答案

你可以使用 selenium 和 PyVirtualDisplay,至少在 linux 上.

You can use selenium with PyVirtualDisplay, at least on linux.

from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(1024, 768))
display.start()
browser = webdriver.Chrome()

这篇关于我可以在不使用 python 打开实际浏览器的情况下将 selenium 与 Scrapy 一起使用吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆