Skip to content

Added movie_details and Jee_result #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions jee_result.py
Original file line number Diff line number Diff line change
@@ -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()
53 changes: 53 additions & 0 deletions movie_details
Original file line number Diff line number Diff line change
@@ -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())