cmiddlebrook Posted July 13, 2010 Share Posted July 13, 2010 I'm using the cURL library to grab some information from a webpage. On a particular site there is an image on the page that i'd like to save to a file but the trouble is, that image is dynamically generated every time. The code contained in the HTML page is as follows: <img src="http://domain.com/branch/" id="graphic" /> (I've changed the real URL). So the URL http://domain.com/branch/ resolved to an actual image file. If I put this in my address bar I get an image file that I can save. So far so good, but I want to grab the image that was contained on the main page that I am looking at - which already has a generated image inside of the img tag. If I go directly to the URL that generates it I get a different image - not the same one. Any ideas? Thanks, Caroline Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 Not sure that's possible in the method you are trying to use, I may be wrong. But it's easier to just recreate the image programmically then to try and pick off a site... now if you want the same dynamic image as is on that page (ie it changes often dynamically) then you'd run a script to recreate it the same as it is being created on that page... or at least have the first page store the instance it used to create it then recreate it using the same instance variables. Quote Link to comment Share on other sites More sharing options...
cmiddlebrook Posted July 13, 2010 Author Share Posted July 13, 2010 Yeah I want to get the image that is on that page and it's tricky because every time the page is reloaded or fetched a new image is generated. How would I store instance variables? Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 I meant somehow saving the variables that are attached to the generation of the image someplace... could be in hidden fields on the page if you want to read the page. Or if sent direclty to another page send it in an array using sessions to create it on another page... a bit beyond my skills so this is speculation really. But maybe it's a start somehow Quote Link to comment Share on other sites More sharing options...
cmiddlebrook Posted July 13, 2010 Author Share Posted July 13, 2010 Unfortunately there are no variables. The domains I'm stuck on are ones that use just a plain URL with no variables to generate an image. Presumably it's a PHP (or similar) file that has some randomisation built in so that every time you visit that url, a new image is generated. Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 What exactly are you trying to do again... & why? I don't see why you'd need to do something like this EDIT: I mean if I understand why may be able to figure something else out or someone with the exact know how may answer if we know exactly why and what you are doing with it... Quote Link to comment Share on other sites More sharing options...
TOA Posted July 13, 2010 Share Posted July 13, 2010 Also post any code you have Quote Link to comment Share on other sites More sharing options...
cmiddlebrook Posted July 13, 2010 Author Share Posted July 13, 2010 I'm trying to grab a captcha image so that I can then pass it to the user to solve, which is why I need to get the exact image that is generated first time around. The code simply does a file_get_contents() on the URL that generates the image and then I save the output of that to a file. The actual saving of the image works... but its the wrong image - the problem is that when I access the URL that generates the image, it is different to the one on the host page. Caroline Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 Ah I see okay... It's different because at every instance you access the site it creates a new dynamic image so file_get_contents() will not work because the server sees the url access as a new request every time thus giving you the wrong image. You would need to have the info the host page used to create the image then. If you don't have access to that then I don't think it's possible.... But now I would really like to know how to solve this if it is though. Devil? any ideas? Quote Link to comment Share on other sites More sharing options...
cmiddlebrook Posted July 13, 2010 Author Share Posted July 13, 2010 Yup that's exactly right. I can't see a way of solving it using the method I'm trying now. But I'm wondering if there is another way of saving the image that has been displayed. It's already rendered in the browser so I wonder if there is a way of telling the browser to save the image that is there without re-accessing the URL that generates it - some kind of caching solution perhaps? I guess these captchas are doing their jobs well as they prevent us pesky programmers from solving them lol! :-) Caroline Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted July 14, 2010 Share Posted July 14, 2010 I guess these captchas are doing their jobs well as they prevent us pesky programmers from solving them lol! :-) Caroline Heh yeah well image that. Ha. Oh well that's my bad pun of the day... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.