I am trying to access to a local website designed with the Symfony framework. It works perfectly with the web browser and with CURL but when I use Mechanize I always got the 401 unauthorized answer for the server.
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
Do you have any idea why it behaves like this?
Thanks
I finally found the answer by myself. There is a bug in the sfDoctrineGuardPlugin (and sfGuardPlugin) that causes this behavior as stated here. I applied the patch and the problem is solved.
there are tight controls on who can access the development environment in symfony. Try using the main URL (probably http://localhost:8080/index.php/home)
Can you refer some valid address to try your code? I guess that you missed some settings, try to disable robots.
br.set_handle_robots(False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With