Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 0a0c77b

Browse files
committed
Added | Rocket Schedule Scrapper
1 parent a42de99 commit 0a0c77b

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Upcoming Rocket Launch Schedule
2+
3+
This script
4+
5+
What it does?
6+
* Scrapes all launch Schedule from https://www.rocketlaunch.live website
7+
* Dumps them into json and csv file
8+
9+
10+
## Pre-Requisites
11+
12+
Run The Command
13+
14+
`pip install -r requirements.txt`
15+
16+
## Instructions To Run
17+
18+
Run The Command in windows
19+
20+
`python main.py`
21+
22+
23+
## *Author Name*
24+
[Rajdeep Ray](https://github.com/Rajdeep-Ray)
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Author : @Rajdeep-Ray
2+
3+
import requests
4+
from bs4 import BeautifulSoup
5+
import json
6+
import csv
7+
8+
c=0
9+
total=0
10+
myList=[]
11+
12+
13+
for s in range(1,8):
14+
s=str(s)
15+
16+
# Using get() method to Open the URL
17+
URL = str("https://www.rocketlaunch.live/?page="+s)
18+
r = requests.get(URL)
19+
20+
soup = BeautifulSoup(r.content, 'html.parser')
21+
f=soup.find_all("h4",{"itemprop":"name"})
22+
f1=soup.find_all("div",{"class":"launch_date rlt_date"})
23+
f2=soup.find_all("div",{"class":"rlt-provider"})
24+
f3=soup.find_all("div",{"class":"rlt-location"})
25+
26+
for j in range(1,len(f),2):
27+
total+=1
28+
myData={}
29+
30+
# get vehicle type
31+
myData['vehicle']=f[j].a.text
32+
33+
# get mission name
34+
myData['mission']=f[j-1].a.text
35+
36+
print("Vehicle :",f[j].a.text)
37+
print("Mission :",f[j-1].a.text)
38+
39+
if(c<len(f1)):
40+
41+
# get lauch date
42+
myData['launch']=f1[c].a.text
43+
44+
# get provider/org name
45+
myData['provider']=f2[c].a.text
46+
47+
# get launch location
48+
myData['location']=f3[c].text.strip().replace("\n", ", ")
49+
50+
print("Launch Date :",f1[c].a.text)
51+
print("Provider :",f2[c].a.text)
52+
print("Location :",f3[c].text.strip().replace("\n", ", "))
53+
print("Data :",myData)
54+
else:
55+
c=0
56+
57+
myList.append(myData)
58+
print()
59+
c+=1
60+
61+
# Prints the total number of results
62+
print("Total Results :",total)
63+
64+
65+
# Create json file
66+
with open("Scripts/Web_Scrappers/Rocket-Schedule/result.json", "w") as outfile:
67+
json.dump(myList, outfile)
68+
print("JSON File created!")
69+
70+
71+
# Create csv file
72+
resultFile = open('Scripts/Web_Scrappers/Rocket-Schedule/Result-file.csv', 'w')
73+
74+
# create the csv writer object
75+
csv_writer = csv.writer(resultFile)
76+
77+
isHeader=False
78+
for emp in myList:
79+
if isHeader==False:
80+
81+
# Writing headers of CSV file
82+
header = emp.keys()
83+
csv_writer.writerow(header)
84+
isHeader=True
85+
86+
# Writing data of CSV file
87+
csv_writer.writerow(emp.values())
88+
89+
resultFile.close()
90+
print("CSV File created!")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
beautifulsoup4==4.9.2
2+
requests==2.24.0

0 commit comments

Comments
 (0)