Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COMP1204-Linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kxt1g21
COMP1204-Linux
Commits
9f8dfd06
Commit
9f8dfd06
authored
2 years ago
by
kxt1g21
Browse files
Options
Downloads
Patches
Plain Diff
(Commit message) curl website with error handling added
parent
a96414f2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data_error_handling.sh
+129
-0
129 additions, 0 deletions
data_error_handling.sh
with
129 additions
and
0 deletions
data_error_handling.sh
0 → 100755
+
129
−
0
View file @
9f8dfd06
#!/bin/bash
date
=
$(
date
+%d-%m-%Y
)
time
=
$(
date
"+%H:%M:%S %p"
)
if
(
curl
-sSf
"https://www.youtube.com/watch?v=F2pQEXieIqM"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
F2pQEXieIqM
>
/home/admin/Documents/cw2/musicPlaylist.html
video1
=
$(
cat
musicPlaylist.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"musicPlaylist,
$video1
,
$date
$time
"
>>
/home/admin/Documents/cw2/musicPlaylist.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('musicPlaylist',
$video1
, default)"
)
else
echo
"musicPlaylist Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=togcVWa-90I"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
togcVWa-90I
>
/home/admin/Documents/cw2/jvkeMusic.html
video2
=
$(
cat
jvkeMusic.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"jvkeMusic,
$video2
,
$date
$time
"
>>
/home/admin/Documents/cw2/jvkeMusic.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('jvkeMusic',
$video2
, default)"
)
else
echo
"jvkeMusic Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=6ZUIwj3FgUY"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
6ZUIwj3FgUY
>
/home/admin/Documents/cw2/iveMusic.html
video8
=
$(
cat
iveMusic.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"iveMusic,
$video8
,
$date
$time
"
>>
/home/admin/Documents/cw2/iveMusic.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('iveMusic',
$video8
, default)"
)
else
echo
"iveMusic Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=a3QioFosUxQ"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
a3QioFosUxQ
>
/home/admin/Documents/cw2/gamingVideo.html
video3
=
$(
cat
gamingVideo.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"gamingVideo,
$video3
,
$date
$time
"
>>
/home/admin/Documents/cw2/gamingVideo.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('gamingVideo',
$video3
, default)"
)
else
echo
"gamingVideo Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=nUPm-loO4FE"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
nUPm-loO4FE
>
/home/admin/Documents/cw2/mukbangVideo.html
video4
=
$(
cat
mukbangVideo.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"mukbangVideo,
$video4
,
$date
$time
"
>>
/home/admin/Documents/cw2/mukbangVideo.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('mukbangVideo',
$video4
, default)"
)
else
echo
"mukbangVideo Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=o_UbEhAYl8Q"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
o_UbEhAYl8Q
>
/home/admin/Documents/cw2/documentary.html
video5
=
$(
cat
documentary.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"documentary,
$video5
,
$date
$time
"
>>
/home/admin/Documents/cw2/documentary.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('documentary',
$video5
, default)"
)
else
echo
"documentary Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=ENkugc7KWbA"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
ENkugc7KWbA
>
/home/admin/Documents/cw2/offlineTVVideo.html
video6
=
$(
cat
offlineTVVideo.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"offlineTVVideo,
$video6
,
$date
$time
"
>>
/home/admin/Documents/cw2/offlineTVVideo.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('offlineTVVideo',
$video6
, default)"
)
else
echo
"offlineTVVideo Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=lYbFLBqJXVc"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
lYbFLBqJXVc
>
/home/admin/Documents/cw2/tenDam.html
video7
=
$(
cat
tenDam.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"tanDam,
$video7
,
$date
$time
"
>>
/home/admin/Documents/cw2/tendam.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('tendam',
$video7
, default)"
)
else
echo
"tenDam Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=YudHcBIxlYw"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
YudHcBIxlYw
>
/home/admin/Documents/cw2/jisooMusic.html
video9
=
$(
cat
jisooMusic.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"jisooMusic,
$video9
,
$date
$time
"
>>
/home/admin/Documents/cw2/jisooMusic.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('jisooMusic',
$video9
, default)"
)
else
echo
"jisooMusic Youtube link error."
fi
if
(
curl
-sSf
"https://www.youtube.com/watch?v=Way9Dexny3w"
>
/dev/null
)
then
curl
-s
https://www.youtube.com/watch?v
=
Way9Dexny3w
>
/home/admin/Documents/cw2/duneTrailer.html
video10
=
$(
cat
duneTrailer.html |
grep
-o
'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+'
|
grep
-o
'[0-9,]\+'
|
sed
's/[^$.0-9]*//g'
)
echo
"duneTrailer,
$video10
,
$date
$time
"
>>
/home/admin/Documents/cw2/duneTrailer.txt
$(
/opt/lampp/bin/mysql
-u
root
-e
"use data; insert into YoutubeViews (Name,Views,DateTime) values ('duneTrailer',
$video10
, default)"
)
else
echo
"duneTrailer Youtube link error."
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment