Skip to content

Instantly share code, notes, and snippets.

@josephjoice
Created September 5, 2017 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephjoice/f0451e73baefca4bb234235c11670f6b to your computer and use it in GitHub Desktop.
Save josephjoice/f0451e73baefca4bb234235c11670f6b to your computer and use it in GitHub Desktop.
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