Skip to content

Instantly share code, notes, and snippets.

@alecxe
Last active August 29, 2015 13:56
Show Gist options
  • Save alecxe/9254060 to your computer and use it in GitHub Desktop.
Save alecxe/9254060 to your computer and use it in GitHub Desktop.
import mechanize
from bs4 import BeautifulSoup
import texttable
med = raw_input("Enter the drugname")
br = mechanize.Browser()
br.set_handle_robots(False)
res = br.open("http://www.medindia.net/drug-price/")
br.select_form("frmdruginfo_search")
br.form['druginfosearch'] = med
br.submit()
soup = BeautifulSoup(br.response().read())
tabl = soup.find('table', {'class': 'content-table'})
table = texttable.Texttable()
for tr in tabl.find_all('tr'):
table.add_row([td.text.strip() for td in tr.find_all('td')])
print table.draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment