LinkFinder icon indicating copy to clipboard operation
LinkFinder copied to clipboard

help me! OSError: [WinError 1] 函数不正确。

Open 0nlyuAarOn opened this issue 4 years ago • 6 comments

我该如何去解救这个报错??

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] 函数不正确。

0nlyuAarOn avatar Aug 26 '19 02:08 0nlyuAarOn

由于您正在用Windows,而Linkfinder 会加 file://D:\LinkFinder-master\gcy.html前面,这样会令路径不正确。

EdOverflow avatar Aug 26 '19 09:08 EdOverflow

please write in English how to fix this.

OVERPEY avatar Oct 03 '21 19:10 OVERPEY

由于您正在用Windows,而Linkfinder 会加 file://D:\LinkFinder-master\gcy.html前面,这样会令路径不正确。

And how can we then fix it ?

ProgramFilesx86 avatar Mar 20 '22 18:03 ProgramFilesx86

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)

hid3rx avatar May 28 '22 04:05 hid3rx

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 函数不正确

QGB avatar Jul 24 '22 10:07 QGB

hid3rx的代码尝试了,可行,把整体复制进去,旧的代码注释掉就可以了

HellQqppt avatar Sep 04 '23 17:09 HellQqppt