Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>UPD</strong> Regarding your comment. Here's my test file:</p> <pre><code>#!/usr/bin/env python import mechanize import cookielib 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() print br.response().read() </code></pre> <p>And this is what I get when running it:</p> <pre><code>$ ./test.py | grep HUM &lt;td valign="top" class="product_table" height="24"&gt;&lt;a href="index.cfm?fuseaction=Search.Overview&amp;DrugName=HUMULIN%20R"&gt; HUMULIN R INSULIN RECOMBINANT HUMAN &lt;td valign="top" class="product_table" height="24"&gt;&lt;a href="index.cfm?fuseaction=Search.Overview&amp;DrugName=HUMULIN%20R%20PEN"&gt; HUMULIN R PEN INSULIN RECOMBINANT HUMAN </code></pre> <p>Maybe you've somehow changed your script or query a different page?</p> <hr> <p>Have you tried to submit this form in a browser?</p> <p>If I navigate to <a href="http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm?fuseaction=Search.Addlsearch_drug_name" rel="nofollow">this URL</a>, fill in "Option B" with "018780" and hit "Submit", the browser indeed redirects me to <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>, which contains the search results.</p> <p>Try adding this to the end of your code snippet:</p> <pre><code>print br.response().read() </code></pre> <p>This will output the HTML of the page, and it does contain search results as expected. </p> <blockquote> <p>I see that the second url does not contain my query text, does that mean i need cookies? if so, how?</p> </blockquote> <p>This form is sent via POST, and in this case all parameters are embedded in request body (RFC 2616).</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.
 

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