Hi !
I just got the idea of making a little tutorial about "how to make a name leecher in VB.Net", so why not ?
In this tutorial, I'm gonna cover:
- How to download the source code of the page
- How to use RegEx to grab all the name
- How to use Threading (Obviously)
- How to export the names in a textfile
Note that this tutorial will be about #. For over tracker, you'll just need to adapt the RegEx code.
We're gonna make something really simple:
![[Image: 3281a91f6cc55fe6051ed6ea5df00b2e.png]](https://gyazo.com/3281a91f6cc55fe6051ed6ea5df00b2e.png)
Make something like this.
Create a new sub, call it something like "GetNames", and add a parameter "page", as Integer. We're gonna use a threadpool to make it faster, so we need to tell to the sub which page it have to grab !
First, let's import some DLL:
Now, in the "Grab" button code, we're gonna use launch the tasks, using a ThreadPool, so add this code:
It's easy to understand, so I'm not gonna explain this. For more information about ThreadPool, go to MSDN.
Now, let's see our GetNames sub.
First of all, we need to get the source code of the page.
It's done pretty easily by using the "DownloadString" method of System.Net, so we got:
![[Image: 9ad94de0d3ba872ca868a2748164fb31.png]](https://gyazo.com/9ad94de0d3ba872ca868a2748164fb31.png)
(Note that I'm not declaring a new Webclient "Dim w as new webclient", but just using "New WebClient()", because we won't have the use of it after, and it's faster than using "Using", (lolz))
Now, let's see the source code of the webpage, and more precisely the source behind the name of the torrent:
![[Image: 054d9a45d7c88d8d7b46eedee31e4324.png]](https://gyazo.com/054d9a45d7c88d8d7b46eedee31e4324.png)
So we see
We are gonna use RegEx and define a pattern according to this.
If you don't know what is RegEx, nor how it's work, search for some tutorial, because it's not the point of this tutorial.
Spoiler (Click to View)
We're gonna declare a new RegEx in our GetNames sub:
![[Image: f16fb566f85948a8285e7e77fcdd5686.png]](https://gyazo.com/f16fb566f85948a8285e7e77fcdd5686.png)
The ".*" is used by RegEx to specify "Here, it can be everything, it'll still works". For more information, open a new tab, type Google, and enj0y !
Now, we're gonna look into each match of RegEx into the source.
Pretty simple, isn't it ?
Now, we're gonna get all the names in the line that RegEx gave us !
For that, in the For loop, we're gonna use Split to get the fifth value, between the "". (Because the Fifth value is the name)
Almost finished ! But the returned string start by "Details of", so we're gonna use the Remove method:
And then add the result in our listbox !
We're gonna need an Invoke, because we are in another thread:
Enj0y !
Our sub looks like this now:
![[Image: 0b9b9e99b920e87fc307574edec64bf7.png]](https://gyazo.com/0b9b9e99b920e87fc307574edec64bf7.png)
We're done with the grabber !!1!11!!11!1!
Spoiler (Click to View)
Now, we're gonna ...
It's pretty easy to export them in a text file, and since I'm bored as fuck right now, here's the code:
Put this in the Export button code.
Hope you liked my (long) tutorial !
Cheer,
PsyCh0TyK, French VB.Net h4xx0r.
I just got the idea of making a little tutorial about "how to make a name leecher in VB.Net", so why not ?
In this tutorial, I'm gonna cover:
- How to download the source code of the page
- How to use RegEx to grab all the name
- How to use Threading (Obviously)
- How to export the names in a textfile
Note that this tutorial will be about #. For over tracker, you'll just need to adapt the RegEx code.
I: Making the design
We're gonna make something really simple:
![[Image: 3281a91f6cc55fe6051ed6ea5df00b2e.png]](https://gyazo.com/3281a91f6cc55fe6051ed6ea5df00b2e.png)
Make something like this.
II: Time to code
Create a new sub, call it something like "GetNames", and add a parameter "page", as Integer. We're gonna use a threadpool to make it faster, so we need to tell to the sub which page it have to grab !
First, let's import some DLL:
Code
System.Net
System.Text.RegularExpression
System.ThreadingNow, in the "Grab" button code, we're gonna use launch the tasks, using a ThreadPool, so add this code:
Code
For i = 0 To NumericUpDown1.Value
ThreadPool.QueueUserWorkItem(New WaitCallback(Sub() GetNames(i)))
NextNow, let's see our GetNames sub.
First of all, we need to get the source code of the page.
It's done pretty easily by using the "DownloadString" method of System.Net, so we got:
![[Image: 9ad94de0d3ba872ca868a2748164fb31.png]](https://gyazo.com/9ad94de0d3ba872ca868a2748164fb31.png)
(Note that I'm not declaring a new Webclient "Dim w as new webclient", but just using "New WebClient()", because we won't have the use of it after, and it's faster than using "Using", (lolz))
Now, let's see the source code of the webpage, and more precisely the source behind the name of the torrent:
![[Image: 054d9a45d7c88d8d7b46eedee31e4324.png]](https://gyazo.com/054d9a45d7c88d8d7b46eedee31e4324.png)
So we see
Code
<a href="/torrent/8098367/ATK_Hairy_-_Babybell_bab004_-_4_-_251_pics_in_1_sets" class="detLink" title="Details for ATK Hairy - Babybell bab004 - 4 - 251 pics in 1 sets">ATK Hairy - Babybell bab004 - 4 - 251 pics in 1 sets</a>We are gonna use RegEx and define a pattern according to this.
III: RegEx is so BADASS !
If you don't know what is RegEx, nor how it's work, search for some tutorial, because it's not the point of this tutorial.
Spoiler (Click to View)
We're gonna declare a new RegEx in our GetNames sub:
![[Image: f16fb566f85948a8285e7e77fcdd5686.png]](https://gyazo.com/f16fb566f85948a8285e7e77fcdd5686.png)
The ".*" is used by RegEx to specify "Here, it can be everything, it'll still works". For more information, open a new tab, type Google, and enj0y !
Now, we're gonna look into each match of RegEx into the source.
Code
For Each m As Match In r.Matches(source)
NextIV: Get all that Names, bitch !
Now, we're gonna get all the names in the line that RegEx gave us !
For that, in the For loop, we're gonna use Split to get the fifth value, between the "". (Because the Fifth value is the name)
Code
Dim res As String = m.Value.Split("""")(5)Code
res = res.Remove(0, 12)We're gonna need an Invoke, because we are in another thread:
Code
Invoke(New MethodInvoker(Sub() nameList.Items.Add(res)))Enj0y !
Our sub looks like this now:
![[Image: 0b9b9e99b920e87fc307574edec64bf7.png]](https://gyazo.com/0b9b9e99b920e87fc307574edec64bf7.png)
We're done with the grabber !!1!11!!11!1!
Spoiler (Click to View)
Now, we're gonna ...
V: Export them !!!1!
It's pretty easy to export them in a text file, and since I'm bored as fuck right now, here's the code:
Code
Dim savefile As New SaveFileDialog
With savefile
.Filter = "Text file|*.txt"
.ShowDialog()
End With
If Not savefile.FileName = Nothing Then
Dim [stream] As Stream = savefile.OpenFile
For i = 0 To ListBox1.Items.Count - 1
Dim sw As New StreamWriter([stream])
sw.WriteLine(ListBox1.Items.Item(i).ToString)
sw.Flush()
Next
End IfPut this in the Export button code.
Hope you liked my (long) tutorial !
Cheer,
PsyCh0TyK, French VB.Net h4xx0r.

![[Image: 74529c6f00d6e06ee856e980924ad8df.png]](https://gyazo.com/74529c6f00d6e06ee856e980924ad8df.png)
