LinkFinder
LinkFinder copied to clipboard
help me! OSError: [WinError 1] 函数不正确。
我该如何去解救这个报错??
python3 linkfinder.py -i http://www.baidu.com -d -o gcy.html
Running against: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/jquery/jquery-1.10.2.min_65682a2.js
Running against: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/plugins/every_cookie_4644b13.js
Running against: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/plugins/every_cookie_mac_82990d4.js
Running against: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/global/js/all_async_search_f3b9a2f.js
URL to access output: file://D:\LinkFinder-master\gcy.html
Output can't be saved in gcy.html due to exception: [WinError 1] 函数不正确。
Traceback (most recent call last):
File "linkfinder.py", line 251, in html_save
print("URL to access output: file://%s" % os.path.abspath(args.output))
OSError: [WinError 1] 函数不正确。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "linkfinder.py", line 392, in <module>
html_save(output)
File "linkfinder.py", line 259, in html_save
due to exception: %s" % (args.output, e))
OSError: [WinError 1] 函数不正确。
由于您正在用Windows,而Linkfinder 会加 file://
在 D:\LinkFinder-master\gcy.html
前面,这样会令路径不正确。
please write in English how to fix this.
由于您正在用Windows,而Linkfinder 会加
file://
在D:\LinkFinder-master\gcy.html
前面,这样会令路径不正确。
And how can we then fix it ?
I changed the code like this, and it works:
def html_save(html):
'''
Save as HTML file and open in the browser
'''
# hide = os.dup(1)
# os.close(1)
# os.open(os.devnull, os.O_RDWR)
try:
s = Template(open('%s/template.html' % sys.path[0], 'r').read())
text_file = open(args.output, "wb")
text_file.write(s.substitute(content=html).encode('utf8'))
text_file.close()
print("URL to access output: file://%s" % os.path.abspath(args.output))
file = "file:///%s" % os.path.abspath(args.output)
if sys.platform == 'linux' or sys.platform == 'linux2':
subprocess.call(["xdg-open", file])
else:
webbrowser.open(file)
except Exception as e:
print("Output can't be saved in %s \
due to exception: %s" % (args.output, e))
# finally:
# os.dup2(hide, 1)
d=ctypes.CDLL("fputs.pyd")
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
kernel32.FreeLibrary.argtypes = [ctypes.wintypes.HMODULE]
In [84]: kernel32.FreeLibrary(d._handle)
Out[84]: 1
In [85]: Win.error_code(_)
1
1 - 函数不正确。
kernel32.FreeLibrary OSError WinError 1 函数不正确
hid3rx的代码尝试了,可行,把整体复制进去,旧的代码注释掉就可以了