WEBVTT - This file was automatically generated by VIMEO

0
00:00:07.600 --> 00:00:10.400
Hello and welcome to the video where we

1
00:00:10.400 --> 00:00:13.900
 will create our first dark automation script

2
00:00:13.900 --> 00:00:16.100
 using python in this

3
00:00:16.100 --> 00:00:19.300
 video. We will explain how to do onion links automation.

4
00:00:21.300 --> 00:00:24.600
I know you might not be familiar with everything related to

5
00:00:24.600 --> 00:00:27.900
 Python and we did like a fast go through

6
00:00:27.900 --> 00:00:30.500
 with the Python and the first video but I

7
00:00:30.500 --> 00:00:33.600
 will explain everything as an

8
00:00:33.600 --> 00:00:35.200
 example also for the first video.

9
00:00:36.300 --> 00:00:40.700
so first, I imported three libraries requests

10
00:00:39.700 --> 00:00:42.400
 random and re

11
00:00:43.200 --> 00:00:45.700
so requests is basically for

12
00:00:47.400 --> 00:00:50.400
to get some content and like talk

13
00:00:50.400 --> 00:00:51.400
 with websites.

14
00:00:52.400 --> 00:00:56.000
Okay, so it help us to communicate.

15
00:00:57.100 --> 00:00:59.300
with websites or anything on the internet

16
00:01:00.600 --> 00:01:03.100
and that's what we need in this scenario.

17
00:01:04.400 --> 00:01:08.000
Also random to randomize any integer

18
00:01:07.800 --> 00:01:13.100
 numbers or words

19
00:01:10.100 --> 00:01:14.000
 just

20
00:01:13.800 --> 00:01:17.600
 random helps you to randomize data

21
00:01:16.600 --> 00:01:18.400
 that could be useful.

22
00:01:20.500 --> 00:01:23.400
Or a is related for regular expression that

23
00:01:23.400 --> 00:01:26.400
 I will explain why we need it in this

24
00:01:26.400 --> 00:01:26.500
 group.

25
00:01:27.600 --> 00:01:31.400
And here we have a variable it's called

26
00:01:31.400 --> 00:01:34.700
 new data. It will input so I'm

27
00:01:34.700 --> 00:01:36.700
 taking an input for query.

28
00:01:37.400 --> 00:01:40.900
Okay, and we have a function called scrape.

29
00:01:42.400 --> 00:01:43.400
So how

30
00:01:44.600 --> 00:01:48.200
we should start with this script and

31
00:01:47.200 --> 00:01:50.900
 what's the goal here? So basically

32
00:01:50.900 --> 00:01:53.800
 I'm writing a script to access

33
00:01:53.800 --> 00:01:54.600
 Amia

34
00:01:55.200 --> 00:01:58.300
if you remember Army are the search engine for dark web.

35
00:01:58.300 --> 00:02:01.700
 So the easiest way to get fast onion

36
00:02:01.700 --> 00:02:04.600
 links is through armia automation. So

37
00:02:04.600 --> 00:02:07.300
 we need to access Army using requests.

38
00:02:07.900 --> 00:02:10.300
Okay, and we will do

39
00:02:10.300 --> 00:02:13.200
 a search keyword using this

40
00:02:13.200 --> 00:02:16.300
 variable new data. We will take the query from

41
00:02:16.300 --> 00:02:19.000
 here and we will pass it to the function.

42
00:02:20.100 --> 00:02:24.600
As from the function it will do the scrape so through

43
00:02:23.600 --> 00:02:26.300
 Amia website and then

44
00:02:26.300 --> 00:02:29.300
 we will get the data saved in a text

45
00:02:29.300 --> 00:02:29.600
 file.

46
00:02:30.100 --> 00:02:31.900
So I will explain all of this now.

47
00:02:32.600 --> 00:02:35.800
Okay. So first of all in order

48
00:02:35.800 --> 00:02:39.500
 to create a function basically we start with

49
00:02:39.500 --> 00:02:40.000
 the

50
00:02:40.900 --> 00:02:42.000
Which means Define?

51
00:02:43.200 --> 00:02:46.900
So I defined a function called scrape which

52
00:02:46.900 --> 00:02:50.300
 will do the things for Amia and

53
00:02:49.300 --> 00:02:52.300
 I passed the query that we needed.

54
00:02:53.400 --> 00:02:54.900
from the user

55
00:02:56.200 --> 00:02:57.600
Okay, so this query.

56
00:02:58.200 --> 00:03:01.300
The data is saved in this variable. This variable will be

57
00:03:01.300 --> 00:03:04.900
 passed to the script function.

58
00:03:04.900 --> 00:03:07.300
 Now. Let's maximize this.

59
00:03:08.600 --> 00:03:11.500
Okay, so I created a variable

60
00:03:11.500 --> 00:03:12.700
 your query.

61
00:03:13.600 --> 00:03:16.800
Okay, which takes the new data? Okay.

62
00:03:19.700 --> 00:03:21.300
then I did an if

63
00:03:22.200 --> 00:03:23.400
if the query

64
00:03:24.400 --> 00:03:27.300
Have an amp spaces. We will replace it

65
00:03:27.300 --> 00:03:28.500
 with plus because

66
00:03:29.300 --> 00:03:32.400
When you do a search on

67
00:03:32.400 --> 00:03:34.900
 Amia it will become like this.

68
00:03:37.300 --> 00:03:40.200
Let's say it was a credit card so it will become like credit.

69
00:03:41.200 --> 00:03:42.700
Plus card

70
00:03:44.500 --> 00:03:46.600
but usually when you enter the

71
00:03:48.300 --> 00:03:52.200
the input on Amia you will just type credit

72
00:03:51.200 --> 00:03:53.700
 space cards.

73
00:03:54.400 --> 00:03:54.700
Okay.

74
00:03:55.500 --> 00:03:55.800
so

75
00:03:57.800 --> 00:04:00.500
sadly, it doesn't work like that when

76
00:04:00.500 --> 00:04:01.600
 you're writing a script.

77
00:04:02.300 --> 00:04:05.800
Because it depends on how I'm

78
00:04:05.800 --> 00:04:09.000
 just taking the values. So the

79
00:04:08.200 --> 00:04:11.500
 query is being converted to plus so we

80
00:04:11.500 --> 00:04:15.000
 need to take it as if it's you're doing

81
00:04:14.100 --> 00:04:16.000
 it on the browser.

82
00:04:17.100 --> 00:04:18.500
Okay, so

83
00:04:19.500 --> 00:04:19.700
if

84
00:04:20.700 --> 00:04:21.700
there's spaces.

85
00:04:22.500 --> 00:04:24.300
We will replace the query.

86
00:04:24.900 --> 00:04:28.100
using the function dot replace with the

87
00:04:27.100 --> 00:04:28.200
 Plus

88
00:04:29.000 --> 00:04:29.200
Okay.

89
00:04:30.200 --> 00:04:33.600
Then we created the variable called request.

90
00:04:33.600 --> 00:04:36.300
 And here we use

91
00:04:36.300 --> 00:04:39.600
 the function dot get to communicate with the URL.

92
00:04:39.600 --> 00:04:43.000
 So requests not get this URL

93
00:04:42.100 --> 00:04:44.200
 with the

94
00:04:45.400 --> 00:04:48.100
with the query which is your query.

95
00:04:49.100 --> 00:04:52.900
Okay, and as you can see I use dot format because I

96
00:04:52.900 --> 00:04:55.100
 need to format it in a way to

97
00:04:55.100 --> 00:04:57.900
 be good. I won't get any errors.

98
00:04:58.600 --> 00:04:59.000
Okay.

99
00:05:00.800 --> 00:05:03.200
Then the content will be saved.

100
00:05:04.400 --> 00:05:07.400
Created a variable called content. So all

101
00:05:07.400 --> 00:05:10.300
 the everything from the request will be saved to

102
00:05:10.300 --> 00:05:10.800
 content.

103
00:05:11.700 --> 00:05:14.400
So here the I use the

104
00:05:14.400 --> 00:05:15.700
 regular expression query.

105
00:05:16.600 --> 00:05:18.400
So since I have all the data.

106
00:05:19.500 --> 00:05:20.700
saved and content

107
00:05:21.700 --> 00:05:22.900
now I need to do.

108
00:05:24.400 --> 00:05:25.500
regular expression

109
00:05:28.200 --> 00:05:30.900
to read all the data from the

110
00:05:31.800 --> 00:05:32.500
variable

111
00:05:33.400 --> 00:05:35.600
and check for the onion links, so

112
00:05:36.700 --> 00:05:39.500
Slash W plus / dot onion means

113
00:05:39.500 --> 00:05:42.800
 find anything that ends

114
00:05:42.800 --> 00:05:43.600
 with not onion.

115
00:05:44.200 --> 00:05:45.600
Any word anything?

116
00:05:46.700 --> 00:05:48.100
And would not onion.

117
00:05:48.800 --> 00:05:49.700
Okay, so

118
00:05:52.300 --> 00:05:57.000
Okay, that's our condition saved in this variable. Then

119
00:05:56.500 --> 00:05:59.300
 I created a mine data

120
00:05:59.300 --> 00:05:59.800
 variable.

121
00:06:00.800 --> 00:06:03.600
then here I call the library or a

122
00:06:04.200 --> 00:06:07.200
and I used a function inside our a call Dot find

123
00:06:07.200 --> 00:06:10.500
 all so dot find all it takes two values.

124
00:06:12.100 --> 00:06:15.500
It takes the magic condition and the data

125
00:06:15.500 --> 00:06:17.200
 you have from the website.

126
00:06:17.900 --> 00:06:20.100
so match this

127
00:06:21.200 --> 00:06:21.900
with the data

128
00:06:22.700 --> 00:06:25.800
when you find them it will be saved in the

129
00:06:25.800 --> 00:06:27.900
 mind data as simple as that.

130
00:06:29.400 --> 00:06:33.100
Then I created a variable called and to randomize

131
00:06:32.100 --> 00:06:35.200
 an integer. Basically you talk with

132
00:06:35.200 --> 00:06:38.600
 the library. You call it random Dot and

133
00:06:38.600 --> 00:06:42.000
 integer. I need a number between one and

134
00:06:43.400 --> 00:06:44.400
10,000

135
00:06:45.000 --> 00:06:45.400
okay.

136
00:06:46.700 --> 00:06:48.500
So I created a file name.

137
00:06:50.100 --> 00:06:53.100
It would be called sites and that random integer.

138
00:06:54.300 --> 00:06:57.200
Remember since it's an integer when you're passing an

139
00:06:57.200 --> 00:07:00.700
 integer to string you need to convert it to you

140
00:07:00.700 --> 00:07:02.600
 use the string function.

141
00:07:04.100 --> 00:07:07.800
Then I the print saving to and the

142
00:07:07.800 --> 00:07:08.100
 file name.

143
00:07:09.400 --> 00:07:12.700
Okay, next I did mine data.

144
00:07:14.400 --> 00:07:17.500
I created a list out of it and saved all

145
00:07:17.500 --> 00:07:19.500
 the keys from the data.

146
00:07:21.300 --> 00:07:24.700
So that I have all the values as a

147
00:07:24.700 --> 00:07:24.800
 list.

148
00:07:25.500 --> 00:07:28.300
Okay, because now I need to write it

149
00:07:28.300 --> 00:07:31.100
 in a file to save it on the files that

150
00:07:31.100 --> 00:07:34.000
 we created. Okay, which is called sites.

151
00:07:36.100 --> 00:07:37.400
So I created a loop.

152
00:07:38.700 --> 00:07:41.600
In order to do that so for K and

153
00:07:41.600 --> 00:07:42.300
 mine data.

154
00:07:43.100 --> 00:07:44.300
with open

155
00:07:45.300 --> 00:07:47.000
Here we start writing.

156
00:07:47.900 --> 00:07:50.500
with open the file name

157
00:07:51.200 --> 00:07:54.900
as append meaning the data will

158
00:07:54.900 --> 00:07:57.300
 be added and added and added it won't

159
00:07:57.300 --> 00:07:58.100
 be right on it.

160
00:07:59.700 --> 00:08:02.400
Because if it was W every time

161
00:08:02.400 --> 00:08:06.300
 it inputs new thing it would be something new.

162
00:08:07.100 --> 00:08:09.200
So a band as a new file.

163
00:08:10.300 --> 00:08:13.000
k equal K plus / n it will

164
00:08:15.100 --> 00:08:17.800
every data would be and would slash on.

165
00:08:18.800 --> 00:08:21.300
And here we told it to write new

166
00:08:21.300 --> 00:08:22.500
 file dot right?

167
00:08:23.200 --> 00:08:24.300
And we give it the value.

168
00:08:25.600 --> 00:08:28.200
So print all the file names written to the next

169
00:08:28.200 --> 00:08:29.100
 file name.

170
00:08:29.600 --> 00:08:32.200
And here our job is done starting from here.

171
00:08:33.700 --> 00:08:36.500
But here it's an extra stuff. It's for

172
00:08:36.500 --> 00:08:39.200
 us in order to read it on

173
00:08:39.200 --> 00:08:42.500
 the output more easier. So I told python.

174
00:08:43.200 --> 00:08:44.300
Open the file.

175
00:08:45.500 --> 00:08:48.100
as input file you can name this anything you want

176
00:08:48.100 --> 00:08:51.300
 remember when it comes to us or

177
00:08:51.300 --> 00:08:51.700
 in

178
00:08:53.300 --> 00:08:54.700
the as you can name it as

179
00:08:57.400 --> 00:09:00.500
When it comes to us, sorry, you can name it anything you

180
00:09:00.500 --> 00:09:03.400
 want because it's a reference you gave it and you

181
00:09:03.400 --> 00:09:03.800
 reference.

182
00:09:04.700 --> 00:09:07.400
Okay, what open find them as input file

183
00:09:07.400 --> 00:09:10.100
 here ahead equal.

184
00:09:11.700 --> 00:09:14.400
next input file for x and range 5

185
00:09:14.400 --> 00:09:14.600
 so

186
00:09:16.300 --> 00:09:19.800
In this line of code. I told python please read

187
00:09:19.800 --> 00:09:21.100
 the first five.

188
00:09:22.200 --> 00:09:25.400
Data from the Mind data, which was

189
00:09:25.400 --> 00:09:27.100
 saved in the file name.

190
00:09:28.500 --> 00:09:31.700
Because as you know when you get onion links

191
00:09:31.700 --> 00:09:34.700
 from Amia, you will get thousands and thousands and

192
00:09:34.700 --> 00:09:38.600
 thousands of links. So outputting

193
00:09:37.600 --> 00:09:39.700
 all of it.

194
00:09:40.800 --> 00:09:44.200
Oh and python, will it it

195
00:09:43.200 --> 00:09:44.900
 might crash it?

196
00:09:46.700 --> 00:09:50.500
So I told python give me just the first

197
00:09:49.500 --> 00:09:52.300
 five values. It can be anything.

198
00:09:52.300 --> 00:09:55.300
 It can be turned. It can be 30, but don't go

199
00:09:55.300 --> 00:09:55.800
 beyond that.

200
00:09:56.900 --> 00:10:00.300
Okay next I created contents.

201
00:10:00.900 --> 00:10:03.300
And I told python please remove the

202
00:10:03.300 --> 00:10:03.800
 slash on.

203
00:10:04.500 --> 00:10:04.900
because

204
00:10:05.800 --> 00:10:06.900
since it's a list.

205
00:10:08.100 --> 00:10:09.200
list type data

206
00:10:10.900 --> 00:10:14.000
You will see lots of Slash and at each onion

207
00:10:13.100 --> 00:10:16.700
 link and we don't need that. So here I

208
00:10:16.700 --> 00:10:19.700
 remove the then I printed. Okay, so

209
00:10:19.700 --> 00:10:20.700
 that's that's the code.

210
00:10:21.700 --> 00:10:24.500
But sorry before testing don't forget to

211
00:10:24.500 --> 00:10:25.700
 call the function at the end.

212
00:10:30.500 --> 00:10:30.700
So

213
00:10:32.700 --> 00:10:34.200
Please enter your query.

214
00:10:36.100 --> 00:10:41.100
Which is this line of code? Okay, I need credit cards

215
00:10:39.100 --> 00:10:41.700
 related stuff.

216
00:10:48.300 --> 00:10:49.800
Okay, so we got an error.

217
00:10:50.900 --> 00:10:52.300
Sorry, I removed the range.

218
00:10:53.400 --> 00:10:54.800
Okay, so let's keep it as five.

219
00:10:56.500 --> 00:10:57.400
headers happen

220
00:11:00.000 --> 00:11:00.600
credit

221
00:11:01.900 --> 00:11:04.400
cards should be it should be working now.

222
00:11:05.900 --> 00:11:08.300
Okay, as you can see we got the

223
00:11:08.300 --> 00:11:09.500
 links. That's it.

224
00:11:11.800 --> 00:11:14.300
And now we fully automated how to

225
00:11:14.300 --> 00:11:15.800
 get links through python.

226
00:11:16.500 --> 00:11:19.500
As our first task and a dark web Automation

227
00:11:19.500 --> 00:11:22.400
 and Python and if you want to see the whole

228
00:11:22.400 --> 00:11:23.000
 file.

229
00:11:23.900 --> 00:11:25.000
Let's check it together.

230
00:11:38.100 --> 00:11:38.400
Okay.

231
00:11:39.900 --> 00:11:42.200
That's the five three nine six eight.

232
00:11:44.400 --> 00:11:47.200
Okay, and that's the file?

233
00:11:48.100 --> 00:11:49.400
As you can see lots of links.

234
00:11:53.900 --> 00:11:56.000
And that's it for the video and I

235
00:11:56.500 --> 00:11:59.900
 will see you in the next video where we will access this links

236
00:11:59.900 --> 00:12:02.400
 and get some credit cards.

237
00:12:02.400 --> 00:12:03.400
 That is exposed.
