Note that there are some explanatory texts on larger screens.

plurals
  1. POpython mechanize submitting form kicks me back to root
    primarykey
    data
    text
    <p>i have a mechanize python script written for submitting forms to inquire drug information. and when i run it, it gives me no error message, but when i look at the response, it's not what I see on my browser view-source page. i checked the urls after the submission: </p> <p>here's what I got:</p> <p><a href="http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm" rel="nofollow">http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm</a></p> <p>here's addresses I'm supposed to get:</p> <p><a href="http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm?fuseaction=Search.DrugDetails" rel="nofollow">http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm?fuseaction=Search.DrugDetails</a></p> <p>I see that the second url does not contain my query text, does that mean i need cookies? if so, how?</p> <p>this is my code snippet:</p> <pre><code>br = mechanize.Browser() cj = cookielib.LWPCookieJar() br.set_cookiejar(cj) .... br.addheaders = [('User-agent', 'Mozilla/6.0 (X11; U; i686; en-US; rv:1.9.0.1) Gecko/2008071615 OS X 10.2 Firefox/3.0.1')] fda_url2 = 'http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm?fuseaction=Search.Addlsearch_drug_name' print br.open(fda_url2).geturl() for f in br.forms(): print 'this is a form' print f br.select_form('searchoptionB') br.form['ApplNo'] = '018780' html = br.submit(name = 'Search_Button') print html.geturl() </code></pre> <p>the print form output was:</p> <pre><code>&lt;searchoptionB POST http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm application/x-www-form-urlencoded &lt;HiddenControl(fuseaction=Search.SearchAction) (readonly)&gt; &lt;HiddenControl(SearchType=AddlSearch) (readonly)&gt; &lt;HiddenControl(SearchOption=B) (readonly)&gt; &lt;TextControl(ApplNo=)&gt; &lt;SubmitControl(Search_Button=Submit) (readonly)&gt; &lt;SubmitControl(clearcriteria=Clear) (readonly)&gt;&gt; </code></pre> <p>sorry for the long post ;p</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload