Extract Instagram bio link?

manpreet

Power Member
Joined
Nov 3, 2011
Messages
631
Reaction score
156
Need help. I'm trying to extract the link shared in an instagram bio page (a class="_ng0lj").

How do I request this server side and forward my end-user to it every time they come on my site (ie cross-domain issue so would like to extract server side
 
Your question is, how to extract a page from another profile and paste it into yours?
 
Your question is, how to extract a page from another profile and paste it into yours?

No it's actually quite a wierd request. All I want is the redirrct url that is posted in a user's bio link. Whenever a user comes to my site the server extracts that link and forwards the user to that link:

User comes to my landing page > my wordpress site extract the instagram link > user is sent to that website
 
I don't believe I understand:
Let's try to sort this.
#1 Someone comes to your server (from Google or a link or entering a webpage address directly) and give you his Instagram handle (in a form?)
#2 Your server opens the profile, extracts the link and redirects the user there.
Why would you want to do this? This is the users own link? Surely he could click on it??? Or do you just want to analyze his page?

Or do you mean this:
#1 Someone clicks a link in an instagram profile that links to your server (multiple bios with unique URLs, but on one domain)
#2 You extract the unique part of the URL and redirect the user there.
Effect: You can use one prelander for hundreds of profiles, don't need to set up hundreds of pages and redirects
This would make sense, but has nothing to do with any html in Instagram: your server gets a request with the full URL and can easily redirect, but wouldn't (need to) know the users' Instagram account handle.

Or is it yet something else?
 
Its quite easy, get the instagram user page html using php, python, etc and then use regex to extract the link.

I don't have lots of experience with regular expressions but the following pattern seems to work: <a class="_ng0lj" ([^>]+)>(.+?)<\/a>
 
Thanks for your help both

I don't believe I understand:
Let's try to sort this.
#1 Someone comes to your server (from Google or a link or entering a webpage address directly) and give you his Instagram handle (in a form?)
#2 Your server opens the profile, extracts the link and redirects the user there.
Why would you want to do this? This is the users own link? Surely he could click on it??? Or do you just want to analyze his page?

Or do you mean this:
#1 Someone clicks a link in an instagram profile that links to your server (multiple bios with unique URLs, but on one domain)
#2 You extract the unique part of the URL and redirect the user there.
Effect: You can use one prelander for hundreds of profiles, don't need to set up hundreds of pages and redirects
This would make sense, but has nothing to do with any html in Instagram: your server gets a request with the full URL and can easily redirect, but wouldn't (need to) know the users' Instagram account handle.

Or is it yet something else?

It's a method i am trying and it is more like the first example you gave (the one you didn't understand).

I'll give a better example than my op.

On my instagram bio link is my 1st site link money.com
User comes to my site example.com
My script runs and extracts the long redirect link for money.com eg https://instagram.com/?u=http://money.com/&e=ATOapWjdjA63.....
The user is now directed to this link

Its quite easy, get the instagram user page html using php, python, etc and then use regex to extract the link.

I don't have lots of experience with regular expressions but the following pattern seems to work: <a class="_ng0lj" ([^>]+)>(.+?)<\/a>

I tried something like this before but it didn't work although i know the class is correct how do i say go to instgram page and take out class and forward?
 
So in other words you want to change the link in your bio (most likely quite frequently) and want to have a redirect on a totally different webpage to happen?
And I guess you want to do the redirect in Javascript, reading your IG bio in with an AJAX call and extracting the href.
This is s....l.....o.....w. Plus you risk IG blocks everytime you change the link in the bio.
Wouldn't it be much easier to change the link on the totally different webpage (example.com)?
 
@mnunes532 I'm getting it all wrong, fine. So please enlighten me. Really, I've invested some time thinking into what the hell he'd like to achieve.
I'd very much appreciate someone telling me in straight terms what this is for. Because your code isn't any revelation either. It just extracts a link from a bio. But WHAT FOR????
 
@mnunes532 I'm getting it all wrong, fine. So please enlighten me. Really, I've invested some time thinking into what the hell he'd like to achieve.
I'd very much appreciate someone telling me in straight terms what this is for. Because your code isn't any revelation either. It just extracts a link from a bio. But WHAT FOR????

Lol you want to know his plan, you don't want to help him...
 
i agree, I want to know what he wants to be able to help him. the story he told us is totally confusing and therefore we cannot help him.
I don't think he has a regex problem (which you solved for him), because he could have simply said "what's the right regex to extract the target url from. ... in Python/JS/PHP".
So I believe he will not get a meaningful answer until he defines his problem clearly
Of course I'm curious, but I can also be helpful if I'm asked straight out.
 
What type of programing language are you using? let me know and I can help
you build a regular expression for that language.
Code:
What is Regex: https://www.regular-expressions.info/
https://www.regexmagic.com/
https://www.regexbuddy.com/
 
What type of programing language are you using? let me know and I can help
you build a regular expression for that language.
Code:
What is Regex: https://www.regular-expressions.info/
https://www.regexmagic.com/
https://www.regexbuddy.com/

I'm used to basic javascript and html tbh just to tweak my sites which are wordpress based. Basically my idea was to use document write and then either click() or window.href or something but it's getting the link out I've never done.

@Start Earning you are getting it all wrong...

@manpreet if you have hosting with php, you can use php code. https://pastebin.com/MzG9EqRh

That's super simple coding, I'm not doing any checks (if user has link in bio, if request fails, etc)

Thanks a lot buddy, appreciate your help and effort that your created the pastebin for me, however nothing works (am pasting in wordpress based site). I had someone create me such a code a year ago on freelancer (would rather see if I can do it for free first or get some help) and can remember he used php too but that was google based and he used the api so I can't think of how to do it with instagram.

i agree, I want to know what he wants to be able to help him. the story he told us is totally confusing and therefore we cannot help him.
I don't think he has a regex problem (which you solved for him), because he could have simply said "what's the right regex to extract the target url from. ... in Python/JS/PHP".
So I believe he will not get a meaningful answer until he defines his problem clearly
Of course I'm curious, but I can also be helpful if I'm asked straight out.

With due respect I'm not going to tell you my exact plan/method, but as seen as you were trying to help initially all I am trying to achieve is get the instagram link out for traffic referrer purposes. It's something I'd like to try as opposed to something that's been proven
 
Here's a working php code: https://pastebin.com/NdrsAws3

$default_redirect_link is where they will be redirected to in case some error occurs or the instagram user doesn't have a link in bio. You could do something else, its up to you.

Right now it works this way: you upload it to your server and then call the file like this: domain.com/filename.php?profile=usernamehere and it will redirect the visitor to the proper page. If you want to use javascript instead to take care of redirect, you can replace header("Location......" with

echo $external_url;

and

echo $default_redirect_link;

and then take care of stuff in javascript side.
 
Here's a working php code: https://pastebin.com/NdrsAws3

$default_redirect_link is where they will be redirected to in case some error occurs or the instagram user doesn't have a link in bio. You could do something else, its up to you.

Right now it works this way: you upload it to your server and then call the file like this: domain.com/filename.php?profile=usernamehere and it will redirect the visitor to the proper page. If you want to use javascript instead to take care of redirect, you can replace header("Location......" with

echo $external_url;

and

echo $default_redirect_link;

and then take care of stuff in javascript side.

Thanks again bro. I've used the pastebin coding there must be an issue or something it only redirects me to instagram and not url from bio. Perhaps it's how I'm doing it. Anyway I'll try building on it. Thanks again
 
Thanks again bro. I've used the pastebin coding there must be an issue or something it only redirects me to instagram and not url from bio. Perhaps it's how I'm doing it. Anyway I'll try building on it. Thanks again

works for me when I try katyperry username. Replace the line

$profile = $_GET['profile'];

with

$profile = "katyperry";

and try again
 
works for me when I try katyperry username. Replace the line

$profile = $_GET['profile'];

with

$profile = "katyperry";

and try again

Love you man lol the think works I was just being a retard. The only issue is it doesn't extract the actual redirect link, for example for katy perry it takes:

bit.ly/2GwVEd9

When I want this:

https://l.instagram.com/?u=https://...JY7wSRZnBoPTfyNEXd-8K9wOpkjQXiCLpzbZ7q6SJ9XqC

Programmatically is this possible even or am I barking up the wrong tree?
 
Gotcha,

replace

$external_url = $json_data->entry_data->ProfilePage[0]->graphql->user->external_url;

with

$external_url = $json_data->entry_data->ProfilePage[0]->graphql->user->external_url_linkshimmed;
 
Gotcha,

replace

$external_url = $json_data->entry_data->ProfilePage[0]->graphql->user->external_url;

with

$external_url = $json_data->entry_data->ProfilePage[0]->graphql->user->external_url_linkshimmed;

Legend!! Thank you so much for your help. It works perfectly like i wanted ;)
 
Back
Top