我正在尝试访问使用Symfony框架设计的本地网站。 它与网络浏览器和CURL完美结合,但是当我使用机械化时,我总是得到401服务器未经授权的答案。Symfony和机械化
import mechanize
# Browser
br = mechanize.Browser()
br.set_debug_http(True)
br.set_debug_redirects(True)
br.set_debug_responses(True)
# Does not change anything even if we change thos
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
# Here is my website
r = br.open('http://localhost:8080/frontend_dev.php/home')
html = r.read()
# Show the html source
print html
你知道为什么它的行为如此吗?
谢谢
Symfony命中与否?它会发生什么,你写死(“命中”);在frontend_dev.php文件的顶部? – greg0ire
如果我死了(“命中”);我看到了命中和没有401错误。 – lc2817