本文介绍了等待网页使用Python完全加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法,我可以找出使用网页浏览器或电气特性的包在Python如果我已经打开已经完全或没有加载浏览器窗口?一旦它完全载入我想利用它的屏幕截图并保存。
Is there any way that I can find out using webbrowser or anyother package in Python if a browser window that I've opened has loaded completely or not? Once it's loaded completely I want to take a screenshot of it and save it.
推荐答案
您可以使用例如做到这一点;我不知道这是否是你想要的,虽然。看到这个。
You can do this using e.g. Selenium; I'm not sure if it's what you want, though. See this short guide.
#!/usr/bin/env python
from selenium import selenium
sel = selenium('localhost', 4444, '*firefox', 'http://www.google.com/')
sel.start()
sel.open('/')
sel.wait_for_page_to_load(10000)
sel.stop()
您也可以使用COM挂钩来控制IE(啊):
You could also use COM hooks to control IE (ugh):
import win32com.client
import time
ie = win32com.client.Dispatch( "InternetExplorer.Application" )
ie.Navigate( <some URL> )
time.sleep( 1 )
print( ie.Busy )
有是用于包装所有COM功能模块:。
There's a module that wraps all the COM functionality: IEC.py
.
这篇关于等待网页使用Python完全加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!