51Testing软件测试论坛
标题: 图片原代码怎么获取 [打印本页]
作者: luckystar121 时间: 2019-3-13 10:27
标题: 图片原代码怎么获取
你好,老师,谷歌浏览器怎么获取验证码图片的源代码?
这种形式的代码:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAAXCAYAAABXlyyHAAACSUlEQVRYhdVYzbnDIAxj2uzECpkl187DOzQJsiSb9NLvNacGiDGS/EPbth+jv8bY9mNsr2Ns+xj9dZzv7/F+jm/n+C+vb6uPcLw/2OS/r2/uowrBX1/fVAZvKXT4Lcbpt8gIN3IMfNP+aaef3zZ8UfQcigAMAfUL65sGNyLEhx80z+iqHZXal+2TGlpY7ORNG16OuCeb82NzXx53djLbPlnNgzJ4DReX8gYDt3Owdo7FA277dCR+95YajrHdvhMYiR2NZ437O4a7CfIYB0PGKzZ4DTrCrEw7hwdK2Cc7N0lZeSoY7lYGPsZqpmrH0Rkcu1hhMPkJCktD7wAwomJbhVBV7HFTdkAY3KOTakOV4hi+xiNQrro8jOFMyhmC7AjLyYLyADgEwR2UAc7J0rpeMBxTfXoYK/GY3KKD2uu6R0LBZegyhiezKOsZw6bhuDN3wuxTeeIhEHnXGLCd+W0GoJLBgKJPTR1YFX8tQTFzAljEno+zuHfGsAMxKz1Lhj3qKmtB3TmKsrXZOeYKnI9K8KUrZbiowbOxGvPyYBm2mc7HEzJuS1iiGH6ckuYcqUmkDO9J1haGXQw4BfgWVMHDQ/r6XmXbqAz1D+utxrTzp11o3FK2MXwlr5zx9WWcyl4KjibPrImIHVV+i/qIYc2kmdRdtmSnhskNg5zO1q2B9n4Sw9VtI0N8edEwzmbza4adfQ6vqtOKc80x9cl91P9T4hn0TcHshjC7a85YMGwlrWpsPgE8YS5jCA6XAMNMZm0tXuJzYHw+yGz/AdQJMdGmS44DAAAAAElFTkSuQmCC
在学课程:
Python Selenium3项目实战
作者: 学掌门网校 时间: 2019-3-13 11:39
本帖最后由 博为峰网校 于 2019-3-13 11:42 编辑
现在携程登录验证码方式变了,现在携程登录,若登录多次错误,才会出现验证码,可以用截图方式,代码如下
如去哪儿登录,下面是对元素截图代码
from selenium import webdriverfrom selenium.webdriver.support.select import Select
path= 'C:/Program Files (x86)/Google/Chrome/chromedriver.exe'
from selenium.webdriver.common.action_chains import ActionChains
import time
from PIL import Image
driver=webdriver.Chrome(path)
driver.get("https://user.qunar.com/passport/login.jsp?")
driver.maximize_window()
time.sleep(4)
driver.save_screenshot("qu.png")
imgcode=driver.find_element_by_id("vcodeImg")
left= imgcode.location['x']
top= imgcode.location['y']
right = left+imgcode.size['width']
bottom = top+imgcode.size['height']
im = Image.open("qu.png")
im = im.crop((left,top,right,bottom))
im.save('t.png')
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) |
Powered by Discuz! X3.2 |