Skip to content
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

Request to merge solutions. #4

Merged
merged 1 commit into from
Dec 24, 2018
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
13 changes: 13 additions & 0 deletions Week-1/chay2199/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# GitHeat
# Projects for summer
This program uses modules like urllib, BeautifulSoup, Pandas, Selenium etc to find train schedules when user gives train number as an input.
The train schedule includes the following information:
1) Train Name
2) Operation Dates
3) Arrival Time
4) Departure Time
5) Station Name with code
6) Route
7) Day of running

The information above is printed in json as well as in a table format.
36 changes: 36 additions & 0 deletions Week-1/chay2199/Train+schedule+by+number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# coding: utf-8

# In[10]:


import bs4 as bs
import urllib.request
import pandas as pd
from selenium import webdriver


url = 'https://www.cleartrip.com/trains/'
x = input() #Takes train number as input in the variable x
finalUrl = url + x + '/'

sauce = urllib.request.urlopen(finalUrl).read()

soup = bs.BeautifulSoup(sauce,'lxml')
trainDetails = soup.h1.text

print('Train Details: ',trainDetails)

for spans in soup.find_all('span' , class_ = 'days-op'):
print('Operational Days: ', spans.text)

df1=pd.read_html(finalUrl, header=0)[0]
out = df1.to_json(orient = 'records')

print(out, '\n\n\n\n\n')
print(df1[['Station name (code)', 'Arrives', 'Departs', 'Stop time',
'Distance travelled', 'Day', 'Route']])

driver = webdriver.Firefox() #Opens the site from where information
driver.get(finalUrl) #is taken.

Loading