如何获取python(pywin32)的firefox地址栏url
我需要抓取firefox地址栏。如何获取python的地址栏url?(我需要第二部分其他浏览器chrome和safari抓取地址栏,但firefox急需)如何获取python(pywin32)的firefox地址栏url,python,firefox,pywin32,Python,Firefox,Pywin32,我需要抓取firefox地址栏。如何获取python的地址栏url?(我需要第二部分其他浏览器chrome和safari抓取地址栏,但firefox急需) 谢谢。您需要浏览所有顶部窗口,查看标题是否包含firefox,或者使用spy++检查firefox的窗口类,然后浏览所有子窗口以查找URL,作为起点,执行以下操作 import win32gui def enumerationCallaback(hwnd, results): text = win32gui.GetWindowTex
谢谢。您需要浏览所有顶部窗口,查看标题是否包含firefox,或者使用spy++检查firefox的窗口类,然后浏览所有子窗口以查找URL,作为起点,执行以下操作
import win32gui
def enumerationCallaback(hwnd, results):
text = win32gui.GetWindowText(hwnd)
if text.find("Mozilla Firefox") >= 0:
results.append((hwnd, text))
mywindows = []
win32gui.EnumWindows(enumerationCallaback, mywindows)
for win, text in mywindows:
print text
def recurseChildWindow(hwnd, results):
win32gui.EnumChildWindows(hwnd, recurseChildWindow, results)
print hwnd
# try to get window class, text etc using SendMessage and see if it is what we want
mychildren = []
recurseChildWindow(mywindows[0][0], mychildren)
您还可以使用此模块完成大多数此类任务
您可以发送Alt-D、Ctrl-C和从剪贴板获取。我像互联网内容过滤器一样进入。我需要外部程序调用和检查。这能回答你的问题吗?