Downloading pdf from a site after submitting a form with beautifulsoup
<p>I am currently writing a crawler script with python.I am aware of beautifulsoup packages and have did some simple crawlers.currently am writing a crawler for a site which has four dropdown, after select the four dropdown if I press the download button a pdf will be downloaded.I have tried it by requests with this script.</p>

<pre><code>post_data = {
'select name 1' : 'value 1',
'select name 2' : 'value 2',
'select name 3' : 'value 3',
'select name 4' : 'value 4',
}   

r = requests.post("http://mydemosite.aspx",data=post_data)
</code></pre>

<p>which is not working.I want to use Beautifulsoup to select the four dropdown and make a virtual formsubmit and get the appropriate pdf.Is it possible to acheive this(subbmitting a form) with beautiful soup.</p>

<p>In general, yes, it is possible, but this really depends on a target web-site and what is involved in submitting a form. </p>

<p>If this is a regular HTML form with no javascript involved, you can use packages like <a href="https://github.com/jmcarp/robobrowser" rel="nofollow"><code>RoboBrowser</code></a> or <a href="https://github.com/hickford/MechanicalSoup" rel="nofollow"><code>MechanicalSoup</code></a> which make form submissions easy. These packages are based on <code>requests</code> and <code>BeautifulSoup</code> and you would have access to the "soup" object if needed as well.</p>

python pdf beautifulsoup