python谷歌浏览器怎么配置 python调用谷歌浏览器插件
大家好,如果您还对python谷歌浏览器怎么配置不太了解,没有关系,今天就由本站为大家分享python谷歌浏览器怎么配置的知识,包括python调用谷歌浏览器插件的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!
本文目录
一、怎么用python进行web开发
1、HTML(超文本标记语言)是网页的核心,学好HTML是成为Web开发人员的基本条件。HTML很容易学习的,但也很容易误用,要学精还得费点功夫。
2、随着HTML5的发展和普及,了解HTML5也将成为Web开发人员的必修课。
3、涉及到网页外观时,就需要学习CSS了,它可以帮你把网页做得更美观。
4、利用HTML和CSS模拟一些你所见过的网站的排版和布局(色彩,图片,文字样式等等)。
5、第二步:学习javascript,了解DOM
6、JavaScript是一种能让你的网页更加生动活泼的程序语言。学习JavaScript的基本语法,学会用javascript操作网页中dom元素。
7、接着学习使用一些javascript库,比如jquery是大部分WEB开发人员都喜欢用的,通过Jquery可以有效的提高JavaScript的开发效率。
8、你不必在这上面花太多精力,但对IIS、Apache基本配置要掌握,这方面的知识学起来也相对容易,不会花多长时间。
9、学习一点Unix和Linux的基本知识,因为大部分Web服务器都运行在Unix和Linux平台上。
10、第四步:学好一门服务器端脚本语言
11、服务器端脚本编程(后台开发)也是Web开发人员的基本功之一,你只需挑选一个服务器端脚本语言,然后学好它。
12、目前流行的服务器脚本语言有:php、asp.net、jsp、ruby、python、等。
13、要构建动态页面通常会使用到数据库,常用的数据库有SQLServer、Oracle、MySQL等,它们都会遵循标准的SQL原则。
14、通常asp.net程序使用SqlServer数据库,PHP、java使用Oracle、MySQL数据库。
15、选一个你喜欢的后台编程语言,结合之前学到的html,css,javascript前端技术,实现一个简单的留言本、论坛程序、进而实现一个简单的CMS(内容管理系统)
16、当你掌握了HTML,CSS,JavaScript和服务器端脚本语言后,就应该找一个Web框架加快你的Web开发速度,使用框架可以节约你很多时间。
17、比如.net的MVC,JAVA的SSH,php的cakephp、CodeIgniter、zend,ruby的ROR,python的dijango等等,其实里面都有一些相通之处。
18、整个开发过程你还可能会学习到一些工具的使用:
19、Visio,Dreamweaver,Vistual Studio、elipse、(Vim, EditPlus, Notpad++)、sqlserver、phpmyadmin,各种浏览器以及FireBug的插件,IE下的WebDevelopmentHelper、IETester等。如果你足够用心,你还发掘出很多不错的资源,例如MSDN,W3cSchool,一些前辈的博客,一些技术论坛等等,这都是你未来前进道路上的财富。如还想深入研究,学学http协议,理解什么是无状态,不然你永远做不好WEB开发,研究web程序服务端运行原理,还有tcp/ip,udp协议等。
20、从最简单的HTML到Web框架,内容还是不少,要想精通这里的每一样技术,都得下苦功夫才行。半年的时间,足够你对web开发产生一个有效的认识,这个时候,再思考你进一步学习的方向吧。
二、如何线上部署用python基于dlib写的人脸识别算法
python使用dlib进行人脸检测与人脸关键点标记
Dlib是一个跨平台的C++公共库,除了线程支持,网络支持,提供测试以及大量工具等等优点,Dlib还是一个强大的机器学习的C++库,包含了许多机器学习常用的算法。同时支持大量的数值算法如矩阵、大整数、随机数运算等等。
Dlib同时还包含了大量的图形模型算法。
最重要的是Dlib的文档和例子都非常详细。
这篇博客所述的人脸标记的算法也是来自Dlib库,Dlib实现了One Millisecond Face Alignment with an Ensemble of Regression Trees中的算法
这篇论文非常出名,在谷歌上打上One Millisecond就会自动补全,是CVPR 2014(国际计算机视觉与模式识别会议)上的一篇国际顶级水平的论文。毫秒级别就可以实现相当准确的人脸标记,包括一些半侧脸,脸很不清楚的情况,论文本身的算法十分复杂,感兴趣的同学可以下载看看。
Dlib实现了这篇最新论文的算法,所以Dlib的人脸标记算法是十分先进的,而且Dlib自带的人脸检测库也很准确,我们项目受到硬件所限,摄像头拍摄到的画面比较模糊,而在这种情况下之前尝试了几个人脸库,识别率都非常的低,而Dlib的效果简直出乎意料。
相对于C++我还是比较喜欢使用python,同时Dlib也是支持python的,只是在配置的时候碰了不少钉子,网上大部分的Dlib资料都是针对于C++的,我好不容易才配置好了python的dlib,这里分享给大家:
因为是用python去开发计算机视觉方面的东西,python的这些科学计算库是必不可少的,这里我把常用的科学计算库的安装也涵盖在内了,已经安装过这些库的同学就可以忽略了。
大家都知道Ubuntu是自带python2.7的,而且很多Ubuntu系统软件都是基于python2.7的,有一次我系统的python版本乱了,我脑残的想把python2.7卸载了重装,然后……好像是提醒我要卸载几千个软件来着,没看好直接回车了,等我反应过来Ctrl+ C的时候系统已经没了一半了…
所以我发现想要搞崩系统,这句话比rm-rf还给力…
sudo apt-get remove python2.71
首先安装两个python第三方库的下载安装工具,ubuntu14.04好像是预装了easy_install
sudo apt-get install python-pip1
sudo apt-get install python-setuptools1
有时候系统环境复杂了,安装的时候会安装到别的python版本上,这就麻烦了,所以还是谨慎一点测试一下,这里安装一个我之前在博客中提到的可以模拟浏览器的第三方python库测试一下。
在终端输入python进入python shell
进入python shell后import一下刚安装的mechanize
没有报错,就是安装成功了,如果说没有找到,那可能就是安装到别的python版本的路径了。
没有报错的话,说明PIL已经被预装过了
首先需要安装python-dev才可以编译之后的扩展库
sudo apt-get install python-dev1
之后就可以用easy-install安装numpy了
这里有时候用easy-install安装numpy下载的时候会卡住,那就只能用 apt-get来安装了:
不推荐这样安装的原因就是系统环境或者说python版本多了之后,直接apt-get安装numpy很有可能不知道装到哪个版本去了,然后就很麻烦了,我有好几次遇到这个问题,不知道是运气问题还是什么,所以风险还是很大的,所以还是尽量用easy-install来安装。
下面的安装过程同理,我就从简写了,大家自己每步别忘了测试一下
sudo apt-get install python-scipy1
sudo apt-get install python-matplotlib1
我当时安装dlib的过程简直太艰辛,网上各种说不知道怎么配,配不好,我基本把stackoverflow上的方法试了个遍,才最终成功编译出来并且导入,不过听说18.18更新之后有了setup.py,那真是极好的,18.18我没有亲自配过也不能乱说,这里给大家分享我配置18.17的过程吧:
1.首先必须安装libboost,不然是不能使用.so库的
sudo apt-get install libboost-python-dev cmake1
2.到Dlib的官网上下载dlib,会下载下来一个压缩包,里面有C++版的dlib库以及例子文档,Python dlib库的代码例子等等
我使用的版本是dlib-18.17,大家也可以在我这里下载:
之后进入python_examples下使用bat文件进行编译,编译需要先安装libboost-python-dev和cmake
cd to dlib-18.17/python_examples
./compile_dlib_python_module.bat 123
之后会得到一个dlib.so,复制到dist-packages目录下即可使用
这里大家也可以直接用我编译好的.so库,但是也必须安装libboost才可以,不然python是不能调用so库的,下载地址:
将.so复制到dist-packages目录下
sudo cp dlib.so/usr/local/lib/python2.7/dist-packages/1
最新的dlib18.18好像就没有这个bat文件了,取而代之的是一个setup文件,那么安装起来应该就没有这么麻烦了,大家可以去直接安装18.18,也可以直接下载复制我的.so库,这两种方法应该都不麻烦~
有时候还会需要下面这两个库,建议大家一并安装一下
sudo apt-get install python-skimage1
环境配置结束之后,我们首先看一下dlib提供的示例程序
dlib-18.17/python_examples/face_detector.py源程序:
#!/usr/bin/python# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt## This example program shows how to find frontal human faces in an image. In# particular, it shows how you can take a list of images from the command# line and display each on the screen with red boxes overlaid on each human# face.## The examples/faces folder contains some jpg images of people. You can run# this program on them and see the detections by executing the# following command:#./face_detector.py../examples/faces/*.jpg## This face detector is made using the now classic Histogram of Oriented# Gradients(HOG) feature combined with a linear classifier, an image# pyramid, and sliding window detection scheme. This type of object detector# is fairly general and capable of detecting many types of semi-rigid objects# in addition to human faces. Therefore, if you are interested in making# your own object detectors then read the train_object_detector.py example# program.### COMPILING THE DLIB PYTHON INTERFACE# Dlib comes with a compiled python interface for python 2.7 on MS Windows. If# you are using another python version or operating system then you need to# compile the dlib python interface before you can use this file. To do this,# run compile_dlib_python_module.bat. This should work on any operating# system so long as you have CMake and boost-python installed.# On Ubuntu, this can be done easily by running the command:# sudo apt-get install libboost-python-dev cmake## Also note that this example requires scikit-image which can be installed# via the command:# pip install-U scikit-image# Or downloaded from. import sys
detector= dlib.get_frontal_face_detector()
print("a");for f in sys.argv[1:]:
print("Processing file:{}".format(f))
# The 1 in the second argument indicates that we should upsample the image
# 1 time. This will make everything bigger and allow us to detect more
print("Number of faces detected:{}".format(len(dets))) for i, d in enumerate(dets):
print("Detection{}: Left:{} Top:{} Right:{} Bottom:{}".format(
i, d.left(), d.top(), d.right(), d.bottom()))
dlib.hit_enter_to_continue()# Finally, if you really want to you can ask the detector to tell you the score# for each detection. The score is bigger for more confident detections.# Also, the idx tells you which of the face sub-detectors matched. This can be# used to broadly identify faces in different orientations.if(len(sys.argv[1:])> 0):
dets, scores, idx= detector.run(img, 1) for i, d in enumerate(dets):
print("Detection{}, score:{}, face_type:{}".format(
d, scores[i], idx[i]))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
我把源代码精简了一下,加了一下注释: face_detector0.1.py
#-*- coding: utf-8-*-import sys
from skimage import io#使用dlib自带的frontal_face_detector作为我们的特征提取器detector= dlib.get_frontal_face_detector()#使用dlib提供的图片窗口win= dlib.image_window()#sys.argv[]是用来获取命令行参数的,sys.argv[0]表示代码本身文件路径,所以参数从1开始向后依次获取图片路径for f in sys.argv[1:]:#输出目前处理的图片地址
print("Processing file:{}".format(f))#使用skimage的io读取图片
img= io.imread(f)#使用detector进行人脸检测 dets为返回的结果
dets= detector(img, 1)#dets的元素个数即为脸的个数
print("Number of faces detected:{}".format(len(dets)))#使用enumerate函数遍历序列中的元素以及它们的下标
#left:人脸左边距离图片左边界的距离;right:人脸右边距离图片左边界的距离
#top:人脸上边距离图片上边界的距离;bottom:人脸下边距离图片上边界的距离
print("Detection{}: Left:{} Top:{} Right:{} Bottom:{}"
.format( i, d.left(), d.top(), d.right(), d.bottom()))#也可以获取比较全面的信息,如获取人脸与detector的匹配程度
dets, scores, idx= detector.run(img, 1)
print("Detection{}, dets{},score:{}, face_type:{}".format( i, d, scores[i], idx[i]))
#绘制图片(dlib的ui库可以直接绘制dets)
win.add_overlay(dets)#等待点击
dlib.hit_enter_to_continue()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
分别测试了一个人脸的和多个人脸的,以下是运行结果:
运行的时候把图片文件路径加到后面就好了
python face_detector0.1.py./data/3.jpg12
这里可以看出侧脸与detector的匹配度要比正脸小的很多
人脸检测我们使用了dlib自带的人脸检测器(detector),关键点提取需要一个特征提取器(predictor),为了构建特征提取器,预训练模型必不可少。
除了自行进行训练外,还可以使用官方提供的一个模型。该模型可从dlib sourceforge库下载:
这个库支持68个关键点的提取,一般来说也够用了,如果需要更多的特征点就要自己去训练了。
dlib-18.17/python_examples/face_landmark_detection.py源程序:
#!/usr/bin/python# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt## This example program shows how to find frontal human faces in an image and# estimate their pose. The pose takes the form of 68 landmarks. These are# points on the face such as the corners of the mouth, along the eyebrows, on# the eyes, and so forth.## This face detector is made using the classic Histogram of Oriented# Gradients(HOG) feature combined with a linear
三、python selenium设置浏览器参数
为了避免每次运行程序都打开一个窗口,我们也可以设置无窗口访问,只需添加浏览器参数即可:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
url=' ;
chrome_options.add_argument('--headless')
chrome_options.add_argument('lang=zh_CN.utf-8')
UserAgent='Mozilla/5.0(Windows NT 10.0; Win64; x64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36'
chrome_options.add_argument('User-Agent='+ UserAgent)
driver= webdriver.Chrome(chrome_options=chrome_options)
指定用户文件夹 User Data路径,可以把书签这样的用户数据保存在系统分区以外的分区–-user-data-dir=”[PATH]”
指定缓存Cache路径–-disk-cache-dir=“[PATH]”指定Cache大小,单位Byte–-disk-cache-size=100
禁用Javascript–-disable-javascript#禁止加载所有插件,可以增加速度--disable-plugins
禁用JavaScript--disable-javascript
禁用弹出拦截--disable-popup-blocking
设置代理chrome_options.add_argument('--proxy-server=http://{ip}:{port}')#
关于python谷歌浏览器怎么配置到此分享完毕,希望能帮助到您。
声明:信息资讯网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流,版权归原作者东方体育日报所有。若您的权利被侵害,请联系 删除。
本文链接:http://www.gdxhedu.com/news/179237.html