Last active
August 29, 2015 13:56
-
-
Save alecxe/9254060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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