title: download file using python beautifulsoup and selenium
body: <p>I want to download to download the first pdb file from search result (download link given below name).  I am using python, selenium and beautifulsoup. I have developed code till this point.</p>
  
  <pre><code>import urllib2
  from BeautifulSoup import BeautifulSoup
  from selenium import webdriver
  
  
  uni_id = "P22216"
  
  # set parameters
  download_dir = "/home/home/Desktop/"
  url = "http://www.rcsb.org/pdb/search/smart.do?smartComparator=and&amp;smartSearchSubtype_0=UpAccessionIdQuery&amp;target=Current&amp;accessionIdList_0=%s" % uni_id
  
  print "url - ", url
  
  
  # opening the url
  text = urllib2.urlopen(url).read();
  
  #print "text : ", text
  soup = BeautifulSoup(text);
  #print soup
  print
  
  
  table = soup.find( "table", {"class":"queryBlue"} )
  #print "table : ", table
  
  status = 0
  rows = table.findAll('tr')
  for tr in rows:
      try:
          cols = tr.findAll('td')
          if cols:
              link = cols[1].find('a').get('href')
          print "link : ", link
              if link:
                  if status==1:
                      main_url = "http://www.rcsb.org" + link
                  print "main_url-----", main_url
                  status = False
                  browser.click(main_url)
          status+=1
  
      except:
      pass
  </code></pre>
  
  <p>I am getting form as None.<br>
  How can i download first file in the search list? (i.e. 2YGV  in this case)  </p>
  
  <pre><code>Download link is : /pdb/protein/P32447
  </code></pre>