gpt4 book ai didi

Python Mechanize : HTTP Error 428 Precondition Failed

转载 作者:行者123 更新时间:2023-12-04 16:18:37 30 4
gpt4 key购买 nike

我正在尝试使用 python mechanize 模块在网站上自动化一个过程。

使用以下代码,我将刷新站点,直到找到我想要关注的链接:

            for link in br.links():            
valuable = filter(lambda tpl: tpl[0]=='href', link.attrs)
if len(valuable) == 0:
continue
if 'book.php' in valuable[0][1]:
print link
req = br.follow_link(link)
file_handler = open("level2.html", "w")
file_handler.write(br.response().read())
file_handler.close()
not_done = False
break

一旦我找到包含“book.php”的链接,应用程序就会崩溃并出现以下错误:

File "/home/max/Dokumente/dev/main.py", line 43, in run req = br.follow_link(link)

File "build/bdist.linux-x86_64/egg/mechanize/_mechanize.py", line 569, in follow_link

File "build/bdist.linux-x86_64/egg/mechanize/_mechanize.py", line 203, in open

File "build/bdist.linux-x86_64/egg/mechanize/_mechanize.py", line 255, in _mech_open

mechanize._response.httperror_seek_wrapper: HTTP Error 428: Precondition failed



这意味着什么?我真的想不通。我该如何解决这个错误?

最佳答案

如解释 here :

The origin server requires the request to be conditional. Its typical use is to avoid the "lost update" problem, where a client GETs a resource's state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict.



这可能意味着已处理链接中的 GET 参数突然过时了。

关于Python Mechanize : HTTP Error 428 Precondition Failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35136255/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com