From 7fe190a936056ba6ee71fd70434d3054cd769962 Mon Sep 17 00:00:00 2001 From: mayank satnalika Date: Sat, 23 Jul 2016 23:42:24 +0530 Subject: [PATCH 1/2] created jee_res file Gives the result of student without date of birth --- jee_result.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 jee_result.py diff --git a/jee_result.py b/jee_result.py new file mode 100644 index 00000000000..a616b5bbb20 --- /dev/null +++ b/jee_result.py @@ -0,0 +1,49 @@ +import mechanize +from bs4 import BeautifulSoup +import urllib2 +# Create a Browser +b = mechanize.Browser() + +# Disable loading robots.txt +b.set_handle_robots(False) + +b.addheaders = [('User-agent', + 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98;)')] + +# Navigate +b.open('http://cbseresults.nic.in/jee/jee_2015.htm') + +# Choose a form +b.select_form(nr=0) + +# Fill it out +b['regno'] = '37000304' + +import datetime +currentdate = datetime.date(1997,3,10) +enddate = datetime.date(1998,4,1) +while currentdate <= enddate: + ct=0 + #print currentdate + yyyymmdd=currentdate.strftime("%Y/%m/%d") + ddmmyyyy=yyyymmdd[8:]+"/"+yyyymmdd[5:7]+"/"+yyyymmdd[:4] + print(ddmmyyyy) + b.open('http://cbseresults.nic.in/jee/jee_2015.htm') + b.select_form(nr=0) + b['regno'] = '37000304' + b['dob']=ddmmyyyy + + fd = b.submit() + #print(fd.read()) + soup = BeautifulSoup(fd.read(),'html.parser') + + for writ in soup.find_all('table'): + ct=ct+1; + #print (ct) + if ct==6: + print("---fail---") + else: + print("--true--") + break; + currentdate += datetime.timedelta(days=1) + #print fd.read() From ee13008bc43d3910b4835388f29365cd63e8ce83 Mon Sep 17 00:00:00 2001 From: mayank satnalika Date: Sat, 23 Jul 2016 23:43:32 +0530 Subject: [PATCH 2/2] created moviedetails Gives the details of the movie from IMDB --- movie_details | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 movie_details diff --git a/movie_details b/movie_details new file mode 100644 index 00000000000..9b4f1f1d95e --- /dev/null +++ b/movie_details @@ -0,0 +1,53 @@ +import mechanize +from bs4 import BeautifulSoup +import urllib2 +# Create a Browser +b = mechanize.Browser() + +# Disable loading robots.txt +b.set_handle_robots(False) + +b.addheaders = [('User-agent', + 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98;)')] +nm=raw_input("enter title ") +# Navigate +b.open('http://www.imdb.com/search/title') + +# Choose a form +b.select_form(nr=1) + + +b['title'] = nm + +b.find_control(type="checkbox",nr=0).get("feature").selected = True + + +# Submit +fd = b.submit() + +soup = BeautifulSoup(fd.read(),'html5lib') + +#data= soup.find_all('td',class_="title") +#for div in data: +# links= div.find_all('a') + # for a in links: + # print a['href']; + + +for div in soup.findAll('td', {'class': 'title'},limit=1): + a = div.findAll('a')[0] + print a.text.strip(), '=>', a.attrs['href'] + hht='http://www.imdb.com/'+a.attrs['href'] + print(hht) + page=urllib2.urlopen(hht) + soup2 = BeautifulSoup(page.read(),'html.parser') + print("title of the movie: ") + print(soup2.find(itemprop="name").get_text()) + print("timerun: ") + print(soup2.find(itemprop="duration").get_text()) + print("genre: ") + print(soup2.find(itemprop="genre").get_text()) + print("current IMDB rating:") + print(soup2.find(itemprop="ratingValue").get_text()) + print("summary:") + print(soup2.find(itemprop="description").get_text())