-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdataScrape.py
More file actions
53 lines (42 loc) · 1.45 KB
/
dataScrape.py
File metadata and controls
53 lines (42 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import requests, json, pprint
from bs4 import BeautifulSoup
# awbNumber = 'FMPC0278112092'
def getJSONData(awbNumber):
doc = requests.get('https://portal.ekartlogistics.com/track/' + awbNumber + '/')
soup = BeautifulSoup(doc.content, 'html.parser')
date = soup.find_all(attrs={"data-title": "Date"})
time = soup.find_all(attrs={"data-title": "Time"})
place = soup.find_all(attrs={"data-title": "Place"})
status = soup.find_all(attrs={"data-title": "Status"})
myList = []
for i in range(len(date)):
templist = [
date[i].text,
time[i].text,
place[i].text,
status[i].text
]
myList.append(templist)
userGets = []
# if(order=='ascend'):
# for k in range(len(myList)):
# tempdict = {
# 'date': myList[k][0],
# 'time': myList[k][1],
# 'place': myList[k][2],
# 'status': myList[k][3]
# }
# userGets.append(tempdict)
#
# if(order=='descend'):
for k in range(len(myList)):
tempdict = {
'date': myList[len(myList)-k-1][0],
'time': myList[len(myList)-k-1][1],
'place': myList[len(myList)-k-1][2],
'status': myList[len(myList)-k-1][3]
}
userGets.append(tempdict)
return userGets
# x = getJSONData(awbNumber)
# pprint.pprint(x)