selenium chrome驱动程序限制大规模web抓取

tcbh2hod  于 2021-07-09  发布在  Java
关注(0)|答案(3)|浏览(275)

我计划在我的项目中使用selenium chrome驱动程序,它将用于对多个公共网站(如kayak或skyscanner)进行web抓取。因此将有一个rest-get端点,我的后端将启动headless-chrome来抓取多个网站,并最终返回一个被操纵的json。
我想知道chrome驱动程序的可伸缩性如何,因为它听起来像一个无头chrome示例需要在任何时候启动一个请求。
更新:问题使用谷歌chrome无头

tyg4sfes

tyg4sfes1#

你想过无头镀铬吗?无头镀铬

jobtbby3

jobtbby32#

我不确定你真的需要使用幻影。
chrome在几个月前实现了“无头”模式无头chrome“和phantomjs做的一样,而且做得更好。我听说phantomjs的作者甚至说他们不会再支持它了。
您可以在 selenium 化物中启用无头模式,只需在线:

Configuration.headless = true;
blpfk2vs

blpfk2vs3#

请找出我在实现过程中注意到的幻影js的优缺点,希望对您有所帮助。
欺骗:

1)It will fail to recognize the browser elements like id,xpath,csselector
when compared to chrome driver.
2)If you have login mechanism ,redirects won't work as you expect when compared to chrome driver.
3)You need to manually implement the custom logic for screen shots for the test failures if you need it.
4)If you want to switch between multiple drivers like chrome,html etc then it is very difficult

赞成的意见:

1)Test case execution is faster when compared to chrome driver
2)No browser is required it will run without GUI. 
3)No much configurations are needed when compared to chromedriver.

您也可以使用html驱动程序,它比phantom快得多,但它也有自己的局限性,您需要在实现之前加以注意。

相关问题