Created
September 5, 2017 15:05
-
-
Save josephjoice/f0451e73baefca4bb234235c11670f6b 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 requests | |
from subprocess import call | |
from bs4 import BeautifulSoup | |
for line in open("servicesTocheck.txt"): | |
params = line.split() | |
r=requests.get("http://www.ksrtc.in/oprs-web/forward/booking/avail/services.do?txtJourneyDate="+params[0]+"&startPlaceId="+params[1]+"&endPlaceId="+params[2]+"&ajaxAction=fw&singleLady=&qryType=0") | |
soup = BeautifulSoup(r.content,'html.parser') | |
try: | |
dontWantServices=params[3:] | |
except: | |
print "all services included" | |
count=0; | |
for one in soup.findAll("div", { "class" : "row" }): | |
serviceName=one.find("div",{"class" : "col1"}).text.split()[0] | |
if (serviceName not in dontWantServices): | |
seatsHtml=one.find("span", { "class" : "availCs" }) | |
count+=int(seatsHtml.get('availcs')) | |
print count | |
# if (count>0): | |
# call(["python","sendMail.py",str(count)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment