Re: Automatic form submission and CSRF??
Thanks a lot - that did the trick! Joakim On Sep 27, 1:58 am, Russell Keith-Magee wrote: > On Mon, Sep 27, 2010 at 12:18 AM, Joakim Hove wrote: > > Hello, > > > I have a simple form which has method POST. When I view the form in > > the browser and fill it normally everything works fine. However; the > > plan is to submit this form automagically from a client program - I > > have currently tried with the Python script: > > > #!/usr/bin/python > > import urllib > > params = urllib.urlencode({"passwd": "Hemmelig", > > "user_id" : 1000, > > "subject" : "Tema", > > "extra_addr" : "joakim-h...@gmail.com", > > "date_list" : "10-10-2010", > > "body" : "Lang melding"}) > > > f = urllib.urlopen(form_url , params) > > print f.read() > > > The server just returns error code 403: "No CSRF or session cookie"; > > how can I get around this? Do I have to create a csrfmiddlewaretoken > > on the client (which will not even have Python installed)? > > If it's impractical or impossible to get access to the CSRF token by > GET before POSTing, you can disable CSRF on that single view. See [1] > for details. > > [1]http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions > > Yours, > Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Automatic form submission and CSRF??
Hi, I think you should add the 'django.middleware.csrf.CsrfResponseMiddleware' into your MIDDLEWARE_CLASSES in the settings model. Yours, BR On Mon, Sep 27, 2010 at 7:58 AM, Russell Keith-Magee < russ...@keith-magee.com> wrote: > On Mon, Sep 27, 2010 at 12:18 AM, Joakim Hove > wrote: > > Hello, > > > > I have a simple form which has method POST. When I view the form in > > the browser and fill it normally everything works fine. However; the > > plan is to submit this form automagically from a client program - I > > have currently tried with the Python script: > > > > #!/usr/bin/python > > import urllib > > params = urllib.urlencode({"passwd": "Hemmelig", > > "user_id" : 1000, > > "subject" : "Tema", > > "extra_addr" : "joakim-h...@gmail.com", > > "date_list" : "10-10-2010", > > "body" : "Lang melding"}) > > > > f = urllib.urlopen(form_url , params) > > print f.read() > > > > The server just returns error code 403: "No CSRF or session cookie"; > > how can I get around this? Do I have to create a csrfmiddlewaretoken > > on the client (which will not even have Python installed)? > > If it's impractical or impossible to get access to the CSRF token by > GET before POSTing, you can disable CSRF on that single view. See [1] > for details. > > [1] http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions > > Yours, > Russ Magee %-) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Automatic form submission and CSRF??
On Mon, Sep 27, 2010 at 12:18 AM, Joakim Hove wrote: > Hello, > > I have a simple form which has method POST. When I view the form in > the browser and fill it normally everything works fine. However; the > plan is to submit this form automagically from a client program - I > have currently tried with the Python script: > > #!/usr/bin/python > import urllib > params = urllib.urlencode({"passwd": "Hemmelig", > "user_id" : 1000, > "subject" : "Tema", > "extra_addr" : "joakim-h...@gmail.com", > "date_list" : "10-10-2010", > "body" : "Lang melding"}) > > f = urllib.urlopen(form_url , params) > print f.read() > > The server just returns error code 403: "No CSRF or session cookie"; > how can I get around this? Do I have to create a csrfmiddlewaretoken > on the client (which will not even have Python installed)? If it's impractical or impossible to get access to the CSRF token by GET before POSTing, you can disable CSRF on that single view. See [1] for details. [1] http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Automatic form submission and CSRF??
Hello, I have a simple form which has method POST. When I view the form in the browser and fill it normally everything works fine. However; the plan is to submit this form automagically from a client program - I have currently tried with the Python script: #!/usr/bin/python import urllib params = urllib.urlencode({"passwd": "Hemmelig", "user_id" : 1000, "subject" : "Tema", "extra_addr" : "joakim-h...@gmail.com", "date_list" : "10-10-2010", "body" : "Lang melding"}) f = urllib.urlopen(form_url , params) print f.read() The server just returns error code 403: "No CSRF or session cookie"; how can I get around this? Do I have to create a csrfmiddlewaretoken on the client (which will not even have Python installed)? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: automatic form submission
> 1. check a specific checkbox in the search form > 2. submit the search form > 3. save in a file the html source of the webpage displaying the search > results Try ClientForm...it is an awesome library for this purpose. Check it out at http://wwwsearch.sourceforge.net/ Cheers Thejaswi Puthraya --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: automatic form submission
On 8/8/07, cesco <[EMAIL PROTECTED]> wrote: > > Hi, > > I need to retrieve automatically some information from an e-commerce > site. > The site doesn't offer any API, so the only way to perform the search > is via the form they provide. The form is submitted via a POST method > and the URL doesn't change after clicking the search button even if I > select different search criteria (which are only checkboxes). > Do you know of any way to automatically or do you have any suggestion > on to automatically perform the following? > > 1. check a specific checkbox in the search form > 2. submit the search form > 3. save in a file the html source of the webpage displaying the search > results > > Any help would be very appreciated. You can use the httplib.HTTPConnection() to do just that. See here: http://www.python.org/doc/2.4.3/lib/httplib-examples.html You should be able to substitute httplib.HTTPSConnection() in place of httplib.HTTPConnection() if your Python's socket library was compiled with SSL support. You might also want to look into pycurl if you want to do more advanced stuff: http://pycurl.sourceforge.net/ HTH. -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
automatic form submission
Hi, I need to retrieve automatically some information from an e-commerce site. The site doesn't offer any API, so the only way to perform the search is via the form they provide. The form is submitted via a POST method and the URL doesn't change after clicking the search button even if I select different search criteria (which are only checkboxes). Do you know of any way to automatically or do you have any suggestion on to automatically perform the following? 1. check a specific checkbox in the search form 2. submit the search form 3. save in a file the html source of the webpage displaying the search results Any help would be very appreciated. Thanks Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---