简体   繁体   English

我可以在没有实际浏览器打开python的情况下使用Selenium和Scrapy

[英]Can i use selenium with Scrapy without actual browser opening with python

I want to do some web crawling with scrapy and python. 我想用scrapy和python进行一些网络爬行。 I have found few code examples from internet where they use selenium with scrapy. 我发现很少有来自互联网的代码示例,他们使用selenium和scrapy。

I don't know much about selenium but only knows that it automates some web tasks. 我对selenium但只知道它会自动化一些网络任务。 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. 但我不希望实际的浏览器打开,但我想从命令行发生一切。

Can i do that in selenium and scrapy 我可以在硒和scrapy中做到这一点

Updated: PhantomJS is abandoned, and you can use headless browsers directly now, such like Firefox and Chrome! 更新:PhantomJS已被放弃,您现在可以直接使用无头浏览器,例如Firefox和Chrome!


Use PhantomJS instead. 请改用PhantomJS。

You can do browser = webdriver.PhantomJS() in selenium v2.32.0. 您可以在selenium v​​2.32.0中执行browser = webdriver.PhantomJS()

You can use selenium with PyVirtualDisplay , at least on linux. 您可以将selenium与PyVirtualDisplay一起使用 ,至少在linux上使用。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不关闭和打开每个元素的浏览器的情况下单击并打开 python selenium 元素中的对象集合 - How do I click and open a collection of objects in an element in python selenium without closing and opening the browser for each element Python:在浏览器上打开本地 html 文件,而不使用 Webbrowser 或 Selenium - Python : Opening local html file on browser without using Webbrowser or Selenium 无法看到使用Python Selenium打开Chrome浏览器的结果 - Can't see result of opening Chrome browser with Python Selenium 在不打开浏览器的情况下阅读 selenium 中的 javascript 代码 - Read javascript code in selenium without opening browser 在没有实际打开浏览器并获取表格内容的情况下,如何使用 selenium? Python - How could I use selenium without actually open the browser and get the table content? Python Python、selenium - 如何在不显示浏览器窗口的情况下运行脚本 - Python, selenium - How can I run the script without showing the browser window 如何在不实际打开浏览器的情况下使用Python向服务器发送URL请求(“不使用webbrowser模块”)? - How can I send a URL request to the server with Python without actually opening my browser (“without using the webbrowser module”)? 使用Selenium WebDriver和Python打开浏览器时出错 - Error in opening browser using selenium webdriver and python Firefox 无法在 selenium python 中使用浏览器打开 - firefox not opening using browser in selenium python WebdriverManager 问题:Chrome 浏览器无法使用 Selenium +Python 打开 - WebdriverManager issue : Chrome Browser not opening with Selenium +Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM