How to link to an Image that the file name keep changing |
How to link to an Image that the file name keep changing |
johnjj |
Jun 5 2015, 03:54 PM
Post
#1
|
Group: Members Posts: 6 Joined: 5-June 15 Member No.: 22,691 |
I want to link to the first image
here for example but the file name is changing every X minutes, so how can I embed this image in my site? thank you |
pandy |
Jun 5 2015, 05:49 PM
Post
#2
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,737 Joined: 9-August 06 Member No.: 6 |
I don't see how you could.
|
Brian Chandler |
Jun 6 2015, 09:20 AM
Post
#3
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
You write a script to fetch the page, scan through for the first
<div align="center"> then get the next src= argument. It's actually very simple, but you have to worry about whether the "owners" of the image mind if you do, etc etc. |
johnjj |
Jun 6 2015, 12:07 PM
Post
#4
|
Group: Members Posts: 6 Joined: 5-June 15 Member No.: 22,691 |
Thanks, it's for my personal use, but I do not know to write a script so if someone is willing to help me with this I would be very happy
|
Brian Chandler |
Jun 6 2015, 01:22 PM
Post
#5
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
You need a server on which you can run scripts in PHP or equivalent. There are a number of functions in PHP which will fetch a file from a URL, e.g. http://php.net/manual/en/function.file-get-contents.php
Then you need to read through the file to find the right bits. I have some utilities which help with this, but you need to be writing the script; you can't really expect that someone will just "do it for you". |
johnjj |
Jun 6 2015, 01:32 PM
Post
#6
|
Group: Members Posts: 6 Joined: 5-June 15 Member No.: 22,691 |
ok. I have the server and I can try to write it through examples from the internet but I don't understand how to use it on the HTML. just the line for the image to show up
|
Brian Chandler |
Jun 7 2015, 03:14 AM
Post
#7
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
ok. I have the server and I can try to write it through examples from the internet but I don't understand how to use it on the HTML. just the line for the image to show up Well, here's a start: if this works, it will just show how many bytes long the web page is. If it doesn't work, it may mean you are not set up to do stuff like this. CODE <?PHP $url = 'http://wind.co.il/%D7%9E%D7%96%D7%92-%D7%90%D7%95%D7%99%D7%A8/%D7%A9%D7%99%D7%93%D7%95%D7%A8-%D7%97%D7%99/'; // Encoding is UTF-8 $urlhtml = htmlspecialchars($url); // version we can echo $rawpage = file_get_contents($url); if (!$rawpage) // NULL return for failure { echo "<p>*** Failed to open page: <tt>$urlhtml</tt>"; } else { // success! $len = strlen($rawpage); echo "<p>Read page: $len // ... now go through to extract file name } // end getting file() ?> |
johnjj |
Jun 7 2015, 07:50 AM
Post
#8
|
Group: Members Posts: 6 Joined: 5-June 15 Member No.: 22,691 |
Thanks for the help Brian, I checked with two files if the server fits:
in one file 333.php I wrote: <html> <body> <h1>Hellow</h1> <p>Bla bla</p> <p>hi hi</p> <?php include '444.php';?> </body> </html> At the second file 444.php I wrote: <?php echo "<p>from 1999-" . date("Y") . " Test.com</p>"; ?> Then when I browse to the file 333.php I get: Hellow Bla bla hi hi from 1999-2015 Test.com Which means that PHP runs on the server properly. How am I supposed to use the code you wrote? I tried the same way and it seems that there is a mistake: Parse error: syntax error, unexpected $ end in D:(path) \ filename.php on line 19 This post has been edited by johnjj: Jun 7 2015, 07:51 AM |
Brian Chandler |
Jun 7 2015, 09:36 AM
Post
#9
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
Sorry, ...
echo "<p>Read page: $len I missed the end off, leaving an open " with no closing " (yes?) So... echo "<p>Read page: $len</p>"; |
johnjj |
Jun 7 2015, 09:44 AM
Post
#10
|
Group: Members Posts: 6 Joined: 5-June 15 Member No.: 22,691 |
Great - now I get
Hellow Bla bla hi hi Read page: 44482 so what now |
Brian Chandler |
Jun 7 2015, 11:31 PM
Post
#11
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
Great - now I get Hellow Bla bla hi hi Read page: 44482 so what now So that looks promising -- the program has now got th 44482 bytes of the page in the string $rawpage. All you have to do is extract the right image name from this string. But the page in question seems to have changed: here's where I think the relevant image was shown: CODE <div align="center"> <br> <a href="http://wind.co.il/fin042336.jpg"> <img src="http://wind.co.il/fin042336.jpg" alt=""> </br> </div> <br> However, currently this image is not found. Perhaps you know if this is temorary. I was going to suggest that you skip through the string to the first occurrence of '<div align="center">', then extract the url after "src=". You need to use functions like http://php.net/manual/en/function.strstr.php ... see what you can work out on your own. Incidentally, I see no point in including a file within another file. Just include this snippet of program within the actual file where you want to show the image. (Someone ought to move this to server scripting really...) |
Lo-Fi Version | Time is now: 15th June 2024 - 04:43 PM |