大家好,很高兴再次与大家见面,我是你们的朋友全栈君。
相信大家在Windows系统上使用谷歌Chrome浏览器都已经得心应手了吧。今天,我要给大家分享一篇特别的文章,教大家如何在Linux纯命令行环境下玩转谷歌Chrome浏览器。边看欧洲杯,边欣赏足球宝贝,这绝对是一次有趣的体验!
接下来,我将详细介绍如何在Linux纯命令行中使用谷歌Chrome浏览器,完成搜索、截图、访问网页等功能。
一、新建一个yum源
首先,我们需要新建一个yum源文件。执行以下命令:
[root@harbor ~]# vim /etc/yum.repo.d/google-chrome.repo
二、修改为以下内容
在新建的文件中,添加以下内容:
[google-chrome] name=google-chrome baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64 enabled=1 gpgcheck=1 gpgkey=https://dl.google.com/linux/linux_signing_key.pub
三、使用yum安装谷歌浏览器
接下来,使用yum命令安装谷歌浏览器:
[root@harbor ~]# yum -y install google-chrome-stable --nogpgcheck
四、查看谷歌浏览器版本
安装完成后,可以查看谷歌浏览器的版本信息:
#查看Google浏览器版本信息 [root@harbor ~]# google-chrome -version Google Chrome 91.0.4472.106 [root@harbor ~]#
五、命令行玩谷歌浏览器
1、命令行使用百度搜索
在命令行中,可以直接使用谷歌浏览器进行百度搜索,并截图保存搜索结果:
#直接输入百度及搜索内容 #截屏百度 [root@harbor tmp]# google-chrome --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com/ [0615/170830.274431:WARNING:headless_browser_main_parts.cc(106)] Cannot create Pref Service with no user data dir. [0615/170830.329462:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is swiftshader [0615/170831.542038:INFO:headless_shell.cc(648)] Written to file screenshot.png.
2、查看搜索结果图片 screenshot.jpg
执行上述命令后,搜索结果的截图会保存为screenshot.png文件:
#截屏百度 [root@harbor tmp]# google-chrome --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com/ [0615/170830.274431:WARNING:headless_browser_main_parts.cc(106)] Cannot create Pref Service with no user data dir. [0615/170830.329462:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is swiftshader [0615/170831.542038:INFO:headless_shell.cc(648)] Written to file screenshot.png.
效果如下 ↓ ↓ ↓
4、命令行搜索欧洲杯足球宝贝
在命令行中搜索欧洲杯足球宝贝,并保存搜索结果:
#查看欧洲杯足球宝贝的搜索结果 [root@harbor tmp]# google-chrome --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com/s?wd=%E8%B6%B3%E7%90%83%E5%AE%9D%E8%B4%9D [0615/170830.274431:WARNING:headless_browser_main_parts.cc(106)] Cannot create Pref Service with no user data dir. [0615/170830.329462:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is swiftshader [0615/170831.542038:INFO:headless_shell.cc(648)] Written to file screenshot.png.
5、命令行打开欧洲杯图片如下:
六、百度搜索内容查看
1、搜索命令
在命令行中,使用以下命令可以搜索并查看百度搜索结果:
[root@localhost tmp]# google-chrome-stable --no-sandbox --headless --disable-gpu --dump-dom https://www.baidu.com/
2、打开百度,打印搜索结果
执行上述命令后,搜索的内容会以HTML格式输出:
3、效果如下
例如,使用百度搜索csdn,结果如下:
发布者:全栈程序员栈长,转载请注明出处:https://www.php.cn/link/fc524d9465535e3f32c487236668155f
以上就是球迷 如何在Linux纯命令行玩转谷歌浏览器,边看欧洲杯,边看足球宝贝[通俗易懂]的详细内容,更多请关注php中文网其它相关文章!
谷歌浏览器Google Chrome是一款可让您更快速、轻松且安全地使用网络的浏览器。Google Chrome的设计超级简洁,使用起来得心应手。这里提供了谷歌浏览器纯净安装包,有需要的小伙伴快来保存下载体验吧!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号