我有一个 python 脚本,它在我的本地机器上运行良好,但是当我将它复制到云函数时它不再工作了。问题是这个soup.find。我刮了一个页面,我想在这里获取值作为 Sessions 令牌。我用
soup = BeautifulSoup(response.content, "html.parser")
session_token = soup.find('input')['value']
这在我的本地机器上运行良好,但在云功能中它给了我以下错误
Output Complete
$
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
日志:
line 30, in client_main session_token = soup.find('input')['value'] TypeError: 'NoneType' object is not subscriptable