Hack Forums
[.NET] Instagram Image Downloader - Commented Source Code // Learning Purposes Tool - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Instagram Image Downloader - Commented Source Code // Learning Purposes Tool (/showthread.php?tid=4631312)

Pages: Pages 1 2


Instagram Image Downloader - Commented Source Code // Learning Purposes Tool - Karnaugh - Jan 11, 2015

Will soon update this into ASP.Net, so it's easier to use.

We all know Instagram doesn't let us download the images without having to go into Inspect Element or some sort of Add-on, so here's a simple software that does the trick for you (:

Video

Will soon make a mass download feature, which allows you to download the whole Instagram profile images!


Source: Pastebin Link

Please leave a post!

Hope you like this!


* - +Haze - Jan 11, 2015

I think the source code would be more useful than the executable. Post it on pastebin pls with vb.net syntax highlighting. Thanks babe


* - Karnaugh - Jan 11, 2015

(Jan 11, 2015 09:20 AM)+Haze Wrote:  I think the source code would be more useful than the executable. Post it on pastebin pls with vb.net syntax highlighting. Thanks babe

Updated it with the PB link. Hope more people leave the post duh...


* - nathan72389 - Jan 11, 2015

lol @ creating controls just to hold a string.
you should of just made this whole project into a function.

function GetImage(link as string) as image
ect...


* - .cYRil. - Jan 11, 2015

I'm agree with "nathan72389" you could do it with the function and returning the the image
anyway thanks for sharing it is usefull


* - +Bourbon - Jan 11, 2015

Honestly mate, it takes less time and effort to use Inspect Element:

[Image: 6SCSSkB.gif]

No problem doing this for academic purposes though!

Just so this post isn't totally useless: if you do end up creating a website for this, you needn't bother with a server-side technology - just do it on the client-side using JS.


* - +Haze - Jan 11, 2015

OP don't take this as me being an ass, I want to help you learn something different.
To extend of what Nathan said. You could use a function to get the image url of your instagram URL. And you could use a regex pattern to get the download URL of the URL instead of using that GetBetween which I don't quiet understand.

You can created a shared class. I'm gonna name mine InstagramHelper.vb

Code
Imports System.Net
Imports System.Text.RegularExpressions
Public Class InstagramHelper

    Private Shared Regex As Regex

    Public Shared Function GetImageURL(imgURL As String) As String

      Using wc As New WebClient
      Dim src As String = wc.DownloadString(imgURL)

      Regex = New Regex("http://(.*).jpg")
      Dim match As Match = Regex.Match(src)

      Return match.Groups(0).Value.ToString()
      End Using

    End Function
End Class

You can then call it like.
PHP Code

<?php 
Dim imgURL 
As String = InstagramHelper.GetImageURL("http://instagram.com/p/xPgjyMgUdN/?modal=true")
PictureBox1.Image = New Bitmap(New MemoryStream(New WebClient().DownloadData(imgURL))) 

But like ByteBlast said, it's easier to inspect element. But I guess this could be good for learning purposes.


* - Only3 - Jan 11, 2015

(Jan 11, 2015 10:32 AM)ByteBlast Wrote:  Honestly mate, it takes less time and effort to use Inspect Element:

https://i.imgur.com/6SCSSkB.gif

No problem doing this for academic purposes though!

Just so this post isn't totally useless: if you do end up creating a website for this, you needn't bother with a server-side technology - just do it on the client-side using JS.

😊 do u think b4 u reply dont think u do it this time


(Jan 11, 2015 10:45 AM)+Haze Wrote:  OP don't take this as me being an ass, I want to help you learn something different.
To extend of what Nathan said. You could use a function to get the image url of your instagram URL. And you could use a regex pattern to get the download URL of the URL instead of using that GetBetween which I don't quiet understand.

You can created a shared class. I'm gonna name mine InstagramHelper.vb

Code
...

You can then call it like.
PHP Code

<?php 
Dim imgURL 
As String = InstagramHelper.GetImageURL("http://instagram.com/p/xPgjyMgUdN/?modal=true")
PictureBox1.Image = New Bitmap(New MemoryStream(New WebClient().DownloadData(imgURL))) 

But like ByteBlast said, it's easier to inspect element. But I guess this could be good for learning purposes.

why u need class for something like this ?
and what if u need to do it with 100 images 😊


* - $lick - Jan 11, 2015

Is every image on instagram a jpeg file?


* - Karnaugh - Jan 11, 2015

(Jan 11, 2015 10:45 AM)+Haze Wrote:  OP don't take this as me being an ass, I want to help you learn something different.
To extend of what Nathan said. You could use a function to get the image url of your instagram URL. And you could use a regex pattern to get the download URL of the URL instead of using that GetBetween which I don't quiet understand.

You can created a shared class. I'm gonna name mine InstagramHelper.vb

Code
Imports System.Net
Imports System.Text.RegularExpressions
Public Class InstagramHelper

    Private Const IMG_URL_PATTERN As String = "http://(.*).jpg"
    Private Shared Regex As Regex

    Public Shared Function GetImageURL(imgURL As String) As String

      Try
      Using wc As New WebClient
      Dim src As String = wc.DownloadString(imgURL)

      Regex = New Regex(IMG_URL_PATTERN)
      Dim match As Match = Regex.Match(src)

      Return match.Groups(0).Value.ToString()
      End Using

      Catch ex As WebException
      Throw New Exception(ex.Message)
      End Try

    End Function
End Class

You can then call it like.
PHP Code

<?php 
Dim imgURL 
As String = InstagramHelper.GetImageURL("http://instagram.com/p/xPgjyMgUdN/?modal=true")
PictureBox1.Image = New Bitmap(New MemoryStream(New WebClient().DownloadData(imgURL))) 

But like ByteBlast said, it's easier to inspect element. But I guess this could be good for learning purposes.

Well, don't forget to save it to the folder, because that was the intention. To download the image to the folder, that picturebox is just to show the image (:


* - +Haze - Jan 11, 2015

PictureBox1.Image.Save(Application.Startup & imgURL & ".jpg")


* - stackoverflowin - Jan 11, 2015

Try to use string.Format rather than: var1 & var2 & var3

I've updated your code a little bit and removed some not needed variables.

Updated: https://pastr.me/!/jqVYqb

Apart from that, good work!


* - Naywyn - Jan 11, 2015

(Jan 11, 2015 12:32 PM)StackOverlowin Wrote:  Try to use string.Format rather than: var1 & var2 & var3

I've updated your code a little bit and removed some not needed variables.

Updated: https://pastr.me/!/jqVYqb

Apart from that, good work!

I don't understand that part :

PHP Code

<?php 
Dim imgURL 
As String = Nothing
    Dim id 
As String = Nothing
    Dim path 
As String = Nothing 

Why are you setting variables to nothing ? default values of strings are already nothing, so you don't need to specifiate any value. :)

Also, you should use :

PHP Code

<?php 
Using Web 
As New WebClient
'do
End Using 



* - stackoverflowin - Jan 11, 2015

(Jan 11, 2015 12:55 PM)AeroRev9 Wrote:  I don't understand that part :

PHP Code

<?php 
Dim imgURL 
As String = Nothing
    Dim id 
As String = Nothing
    Dim path 
As String = Nothing 

Why are you setting variables to nothing ? default values of strings are already nothing, so you don't need to specifiate any value. :)

Also, you should use :

PHP Code

<?php 
Using Web 
As New WebClient
'do
End Using 

I didn't change that part of the code, that is the original code :P


* - Odus - Jan 11, 2015

(Jan 11, 2015 12:55 PM)AeroRev9 Wrote:  I don't understand that part :

PHP Code

<?php 
Dim imgURL 
As String = Nothing
    Dim id 
As String = Nothing
    Dim path 
As String = Nothing 

Why are you setting variables to nothing ? default values of strings are already nothing, so you don't need to specifiate any value. :)

You do it to initialize the variable. Avoids null reference cases when reading without assigning a value along with various other reasons.