This is the main link :
When we enter the above link in the browser it will change to :
But this link is dynamic and some parts of above link will change everytime with refresh. I want to extract the m3u8 link after any refresh. The result of extract to be similar this :
Your original link (the static one) is doing a redirect. In order to follow this redirect you have to specify the right option to your crawler.
So if you're using curl for example you should set CURLOPT_FOLLOWLOCATION to true.
Regards
Also note that the format is really simple:
If your original link is formatted:
http://api.hqiptv.net/?{A}/live/0.{B}.m3u8
the redirect will look like:
http://s1.hqiptv.net:8080/live/{timestamp}:{A}/{B}.m3u8?{random string}
Related
I have a simple PHP website. Let's call it youtubex.com. I want to redirect youtubex URLs (in the format shown on STEP2) to my website in the format shown on STEP3. Here, I am using YouTube, just for illustration.
STEP1: https://www.youtube.com/watch?v=lj62iuaKAhU
STEP2: https://www.youtubex.com/watch?v=lj62iuaKAhU
STEP3: https://www.youtubex.com/#url=https://www.youtube.com/watch?v=lj62iuaKAhU
STEP1 shows any desired URL. STEP2 shows the same URL from STEP1 with youtubex as domain. STEP3 shows the final required URL. I am trying to redirect STEP2 to STEP3.
I tried finding some solutions to this on the internet and SO, but, none help. Here is one.
This should do the work:
RedirectMatch 301 /watch$ https://www.youtubex.com/#url=https://www.youtube.com/watch
An inefficient but full php solution can be using the location header in php :
$vid = $_GET['v']
if($vid){ header("location:https://www.youtubex.com/#url=https://www.youtube.com/watch?v=$vid");
}
by the way you can't get the text after the hash mark in php because it is not sent to the server.
javascript can do it in a more neat way without the second reload by checking window.location.href to see if the hash does not exist already and then get the v parameter in url then change url without refreshing the page by using window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);
using php str_replace and header :
$step2_url = "https://www.youtubex.com/watch?v=lj62iuaKAhU";
$part2_url = str_replace("youtubex","youtube",$step2_url);//the output is : https://www.youtube.com/watch?v=lj62iuaKAhU
$step3_url = "https://www.youtubex.com/#url=".$part2_url; //the output is : https://www.youtubex.com/#url=https://www.youtube.com/watch?v=lj62iuaKAhU
now you have the final url , simply redirect
header($step3_url);
I´m having this affiliate link (as seen below). Why does this version of the code redirects to my desired target:
header("Location: https://www.awin1.com/cread.php?s=2079804&v=10954&q=326996&r=456987");
but that version doesn´t lead to my target. Instead it leads to "onepixel.gif"
header("Location: ".$_GET["link"]);
executed as:
linktofile.com/?link=https://www.awin1.com/cread.php?s=2079804&v=10954&q=326996&r=456987
How is the awin server able to distinguish the difference?
If you use the URL as given (linktofile.com/?link=https://www.awin1.com/cread.php?s=2079804&v=10954&q=326996&r=456987), PHP stops to parse the first parameter $_GET['link'] at the latest at the next best ampersand, so it contains at most https://www.awin1.com/cread.php. Follow the advice of RamRaider and encode the URL parameters before rendering the link pointing to your page. It should work if the link is given as linktofile.com/?link=https%3A%2F%2Fwww.awin1.com%2Fcread.php%3Fs%3D2079804%26v%3D10954%26q%3D326996%26r%3D456987
I am trying to share the following link:
https://www.facebook.com/sharer/sharer.php?u=http://www.example.com/test.php/?user=abc&serial=43215
The sharing is ok.But when I am opening the link from facebook, It is not showing the correct link.
Showing like the following link:
http://www.example.com/test.php/?user=abc
and removed these part from the shared link : &serial=43215 .
How can I get the original link like http://www.example.com/test.php/?user=abc&serial=43215?
You can use Facebook Debugger to check your URL and be sure of what is wrong. You should ensure you are setting the correct og tags which are included in your page's header tag. Verify these then you'll be good to go.
Since you are putting one URL as a parameter value into another URL, you must of course properly URL-encode that first URL.
The way you are doing it right now, you are passing two parameters to sharer.php – parameter u with value http://www.example.com/test.php/?user=abc and parameter serial with value 43215.
Since your question includes the tag php, you can simply use urlencode for this:
$shareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' .
urlencode('http://www.example.com/test.php/?user=abc&serial=43215');
I have this link:
www.something.com/index.php?page=teams
I then have this link:
Profile
I want to achieve is this link:
www.something.com/index.php?page=teams&profile=5
But I get this instead:
www.something.com?profile=5
The tricky part is that I can't just write the whole "path" like this:
Profile
Because it isn't always on the page 'teams'.
It might be a pretty stupid question, but i can't really figure it out.
You must include the page=teams parameter in the href.
Instead of
Profile
Something like
Profile
If that link is static you must need to update the html file.
But if page=anyvalue then you must generate the href link dynamically in your php code
for example:
Where $page is the current page, e.g $page="teams"
Well, you can just add it to the query string using http_build_query:
$newQueryString = http_build_query(['profile' => 5] + $_GET);
And then output it to your link:
Profile
Try something like this:
echo '<a href="'.{$_SERVER['SCRIPT_NAME']}.{$_SERVER['QUERY_STRING']}
.'&profile=5">Profile</a>
This makes use of $_SERVER to get the current page name (SCRIPT_NAME) and the existing query string (QUERY_STRING), and then appends "&profile=5" onto the end.
Well i have sort of fixed it.... i created a session called page, so i can access it everywhere. The thing is i can't get the variable $_GET['page'] because it's inside a included file called search.php, therefore i created the session.. But thanks for you suggestions guys!
I'm building a bookmarklet and I need to get the current URL of the webpage the user is on when they activate the bookmarklet.
I tried using
$current_url = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
But that will just get me the URL of the server where the JS for the bookmarklet is hosted. Is there anyway of getting the URL straight from the address bar?
You can resolve the problem by defining your SITE URL (eg: define('SITE_URL', 'http://abc.com')) and concat the site url with $_SERVER['REQUEST_URI']
Eg: $cur_url = SITE_URL.$_SERVER['REQUEST_URI'];
Yes, simply pass location.href form the bookmarklet.
For example;
location.href="http://mywebsite.com/bookie.php?url="+encodeURIComponent(location.href);
Then on your server, you get the URL at $_GET['url']. Good luck.
Of course, that's just JS. You need to add javascript: scheme for it to work.
If by bookmarklet you mean http://en.wikipedia.org/wiki/Bookmarklet than I think this code will help:
javascript:alert(document.location.href);
To test it, select the code and drag it in your bookmark browser bar than click it.