- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我是 Python 编程的新手,我正在尝试使用 Python 的 webbrowser 模块制作脚本以通过网络浏览器打开 URL/IP 地址。
打开 Web 浏览器的实际操作工作正常,但我收到来自 firefox 的日志消息,这些消息向我的脚本运行的终端窗口发送垃圾邮件。虽然它最终并没有阻止脚本执行其工作,但由于错误将它们推到了视线之外,因此很难显示提示。
这些错误似乎是在我退出生成的 Firefox 窗口时引起的。这些是所显示错误的示例:
###!!! [Child][MessageChannel] Error: (msgtype=0x460102,name=PContent::Msg_AsyncMessage) Channel closing: too late to send/recv, messages will be lost
###!!! [Child][MessageChannel] Error: (msgtype=0x2C0048,name=PBrowser::Msg___delete__) Channel closing: too late to send/recv, messages will be lost
我试图通过使用命令将错误消息发送到 null 而不是终端来生成 firefox 实例来缓解这种情况,但这没有帮助:
os.system("firefox &> /dev/null"); time.sleep(1)
#before calling below in a while loop. opens tabs in the same window that opens from the above command.
webbrowser.open("http://" + urls.pop(0) + ":" + port,new=2)
有什么想法吗?
谢谢!
我的整个脚本:
"""This script will open URLs and IP addresses in the default web browser.
Please store all URLs and/or IPs in a file called 'port80.txt'.
Please ignore errors that appear in the terminal upon closing your web browser
(may only affect Firefox on Kali Linux).
Thanks."""
import webbrowser
import time
import sys
import os
#sys.tracebacklimit = 0
counter = 0;port = "0"
while port != "80" and port != "443":
port = raw_input("Port 80 or Port 443?\n")
try:
fileOfURLs = open("port"+port+".txt","r")
except:
print("Could not open file. Check if it exists. Exiting...")
exit()
urls = []
readFile = fileOfURLs.readlines()
for line in readFile:
urls.append(line.strip())
fileOfURLs.close()
#get how many urls/IPs are in the file
amountOfURLs = len(urls)
print("There are " + str(amountOfURLs) + " URLs in this text file.")
print("Please ignore error messages upon exit of a FireFox tab/window.\
I have no idea how to stop these...")
"""Open the tabs. Opens 10 at a time over a 10 second span. Change 'maxtabs' to a
different number if more tabs at a time is preferred."""
maxtabs = 10
while amountOfURLs > 0:
os.system("firefox &> /dev/null"); time.sleep(1)
if amountOfURLs > maxtabs:
counter = maxtabs;amountOfURLs -= maxtabs
elif amountOfURLs > 0 and amountOfURLs < maxtabs:
counter = amountOfURLs; amountOfURLs = 0
while counter > 0:
webbrowser.open("http://" + urls.pop(0) + ":" + port,new=2)
counter-=1
print("There are " + str(counter) + " tabs left to open in this batch.")
time.sleep(1)
raw_input("Press enter to continue...")
print("Done.")
raw_input("Press enter to exit...")
最佳答案
我在这里找到了https://github.com/mozilla/geckodriver/issues/1569该声明:“同样,正如在另一个问题上所说,这是 Firefox 的输出,因此与 geckodriver 无关。”这与 https://github.com/mozilla/geckodriver/issues/1376 有关使用 Java 时会出现相同的错误消息。
关于python - 抑制 Firefox 终端消息 Python/Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49499106/
使用 Guake 终端这个可自定义且强大的适合各种用户的工具快速访问你的终端。 Guake 终端:GNOME 桌面中自上而下终端 Guake 是一款为 GNOME
我是 python 的新手,正在尝试运行 python 2.7 script .获得了 python 2.7 的 pip 并从 mac 终端 shell 安装了 pyCrypto 的依赖项。 我想尝试
我正在寻找一种在 Swift (macOS) 中运行终端命令的方法。我遇到了this发布,但我似乎无法获得任何解决方案。我正在尝试从我的应用程序关闭我的 mac,就像您可以从终端执行的那样(osasc
我在 macOS 上使用 bash 终端。 用户名、计算机名和文件路径占据了大部分行,所以如果我写一个长命令,我会从一行开始,然后在下一行继续。 相反,我希望行光标从用户名和计算机名下方的下一行开始。
是否有一个变量或函数可以告诉我光标的实际位置? #!/usr/bin/env perl use warnings; use 5.012; use Term::ReadKey; use Term::Ca
如何在 Mac Os X(10.6.8) 上的 gnuplot 中启用 tikz 终端? 我有工作 tikz 的 latex 。现在我从 http://www.lua.org/ 安装了 lua并下载g
我正在学习一个名为 Starting a Django 1.4 Project the Right Way 的教程,其中提供了有关如何使用 virtualenv 和 virtualenvwrapper
我正在尝试用java编写一个unix终端模拟器。我有很多麻烦。我似乎无法更改程序的工作目录,因此“cd”等命令无法正常工作。我的问题是,如果我运行一个需要用户输入的命令,有什么方法可以将该输入发送到正
我在这方面完全是个新手(Mac leopard 中的终端),我希望能从网络上获得生命线,因为我确实碰壁了。 我想在终端中以 root 身份运行脚本。该脚本保存为扩展名为 .rtf 的文本文件。我已经插
尝试在我的 osascript 命令中包含引号 ' ' 时遇到了一个奇怪的问题。 如果我尝试转义一个正常的可转义字符,它就可以正常工作。示例: osascript -e 'tell app "Find
我正在制作一个控制台 Java 应用程序,您可以在其中输入控制台命令,例如 Macintosh/Ubuntu/Windows 命令提示符上的终端,然后将其输出到日志。 我想知道,在执行系统/控制台命令
在终端中输入 mysql 命令并按回车键会换行。 但有时当我犯错时,即使用分号结束语句也无法退出此模式。 Ctrl + c 退出mysql。我怎样才能退出插入模式? 最佳答案 你必须用 ';' 结束
我正在尝试编写一个 C 代码来打开 xeyes 应用程序,然后那些眼睛在特定的时间段内不断改变其颜色.. 我尝试通过执行具有一种中心颜色的 xeyes、添加 3 秒的延迟、终止进程并在循环内打开具有另
是否有一种语法允许我在 System.out.println() 行 的同一行中读取用户的输入? 例子: What is your name?:(<-- Output) Jack (<-- In
我有一个 Wordpress 上传文件夹,该文件夹使用子文件夹构建了几个月。 wolfr2:uploads wolfr$ tree . . |-- 2007 | |-- 08 | | |-
如何从 mac 终端使用 sqlite3 找出表的列名?我忘记了我给这些列起的名字,我也不知道这些名字是怎么来的。谢谢! 最佳答案 来自 http://www.sqlite.org/sqlite.ht
我需要我的终端发送一个未使用的控制字符或转义序列,它在所有层都没有效果:被shell(bash,…)忽略,被行编辑器(readline,…)忽略,被所有应用程序(vim,less,mutt,…)忽略。
我做了一个文本编辑器,我想把它移植到 Linux 上,这样我就可以通过 SSH 远程使用它。我不太了解 Linux 终端,所以也许我遗漏了一些明显的东西,因为我简直不敢相信在 2013 年远程终端仍然
我最近想放一个 java 类文件供下载,人们可以在终端中运行它。这是一个 Minecraft 命令生成器,因此下载它的人不一定具有最大的心智能力(当然,我指的是 8 岁的 child ,他们不知道自己
我有一个文件“test.txt”,里面有一个数字列表,就像这样 1 3 4 2 3 40 312 53 243 321 423 ...etc 我还有一个可执行文件,它是一种排序算法,例如 hea
我是一名优秀的程序员,十分优秀!