Hello and welcome to the video where we
will create our first dark automation script
using python in this
video. We will explain how to do onion links automation.
I know you might not be familiar with everything related to
Python and we did like a fast go through
with the Python and the first video but I
will explain everything as an
example also for the first video.
so first, I imported three libraries requests
random and re
so requests is basically for
to get some content and like talk
with websites.
Okay, so it help us to communicate.
with websites or anything on the internet
and that's what we need in this scenario.
Also random to randomize any integer
numbers or words
just
random helps you to randomize data
that could be useful.
Or a is related for regular expression that
I will explain why we need it in this
group.
And here we have a variable it's called
new data. It will input so I'm
taking an input for query.
Okay, and we have a function called scrape.
So how
we should start with this script and
what's the goal here? So basically
I'm writing a script to access
Amia
if you remember Army are the search engine for dark web.
So the easiest way to get fast onion
links is through armia automation. So
we need to access Army using requests.
Okay, and we will do
a search keyword using this
variable new data. We will take the query from
here and we will pass it to the function.
As from the function it will do the scrape so through
Amia website and then
we will get the data saved in a text
file.
So I will explain all of this now.
Okay. So first of all in order
to create a function basically we start with
the
Which means Define?
So I defined a function called scrape which
will do the things for Amia and
I passed the query that we needed.
from the user
Okay, so this query.
The data is saved in this variable. This variable will be
passed to the script function.
Now. Let's maximize this.
Okay, so I created a variable
your query.
Okay, which takes the new data? Okay.
then I did an if
if the query
Have an amp spaces. We will replace it
with plus because
When you do a search on
Amia it will become like this.
Let's say it was a credit card so it will become like credit.
Plus card
but usually when you enter the
the input on Amia you will just type credit
space cards.
Okay.
so
sadly, it doesn't work like that when
you're writing a script.
Because it depends on how I'm
just taking the values. So the
query is being converted to plus so we
need to take it as if it's you're doing
it on the browser.
Okay, so
if
there's spaces.
We will replace the query.
using the function dot replace with the
Plus
Okay.
Then we created the variable called request.
And here we use
the function dot get to communicate with the URL.
So requests not get this URL
with the
with the query which is your query.
Okay, and as you can see I use dot format because I
need to format it in a way to
be good. I won't get any errors.
Okay.
Then the content will be saved.
Created a variable called content. So all
the everything from the request will be saved to
content.
So here the I use the
regular expression query.
So since I have all the data.
saved and content
now I need to do.
regular expression
to read all the data from the
variable
and check for the onion links, so
Slash W plus / dot onion means
find anything that ends
with not onion.
Any word anything?
And would not onion.
Okay, so
Okay, that's our condition saved in this variable. Then
I created a mine data
variable.
then here I call the library or a
and I used a function inside our a call Dot find
all so dot find all it takes two values.
It takes the magic condition and the data
you have from the website.
so match this
with the data
when you find them it will be saved in the
mind data as simple as that.
Then I created a variable called and to randomize
an integer. Basically you talk with
the library. You call it random Dot and
integer. I need a number between one and
10,000
okay.
So I created a file name.
It would be called sites and that random integer.
Remember since it's an integer when you're passing an
integer to string you need to convert it to you
use the string function.
Then I the print saving to and the
file name.
Okay, next I did mine data.
I created a list out of it and saved all
the keys from the data.
So that I have all the values as a
list.
Okay, because now I need to write it
in a file to save it on the files that
we created. Okay, which is called sites.
So I created a loop.
In order to do that so for K and
mine data.
with open
Here we start writing.
with open the file name
as append meaning the data will
be added and added and added it won't
be right on it.
Because if it was W every time
it inputs new thing it would be something new.
So a band as a new file.
k equal K plus / n it will
every data would be and would slash on.
And here we told it to write new
file dot right?
And we give it the value.
So print all the file names written to the next
file name.
And here our job is done starting from here.
But here it's an extra stuff. It's for
us in order to read it on
the output more easier. So I told python.
Open the file.
as input file you can name this anything you want
remember when it comes to us or
in
the as you can name it as
When it comes to us, sorry, you can name it anything you
want because it's a reference you gave it and you
reference.
Okay, what open find them as input file
here ahead equal.
next input file for x and range 5
so
In this line of code. I told python please read
the first five.
Data from the Mind data, which was
saved in the file name.
Because as you know when you get onion links
from Amia, you will get thousands and thousands and
thousands of links. So outputting
all of it.
Oh and python, will it it
might crash it?
So I told python give me just the first
five values. It can be anything.
It can be turned. It can be 30, but don't go
beyond that.
Okay next I created contents.
And I told python please remove the
slash on.
because
since it's a list.
list type data
You will see lots of Slash and at each onion
link and we don't need that. So here I
remove the then I printed. Okay, so
that's that's the code.
But sorry before testing don't forget to
call the function at the end.
So
Please enter your query.
Which is this line of code? Okay, I need credit cards
related stuff.
Okay, so we got an error.
Sorry, I removed the range.
Okay, so let's keep it as five.
headers happen
credit
cards should be it should be working now.
Okay, as you can see we got the
links. That's it.
And now we fully automated how to
get links through python.
As our first task and a dark web Automation
and Python and if you want to see the whole
file.
Let's check it together.
Okay.
That's the five three nine six eight.
Okay, and that's the file?
As you can see lots of links.
And that's it for the video and I
will see you in the next video where we will access this links
and get some credit cards.
That is exposed.