0

What I want to do is following:

  1. User takes screenshot with the application like jing. ok!
  2. Pastes link that Jing returned back. ok!
  3. Server processes the link that user entered, and extracts images source url. But, I have no idea how server will get "clean" image source URL. For example, this is the link that Jing returned after sharing screenshot http://screencast.com/t/zxBzNNkcg but real url of image looks like http://content.screencast.com/users/TT13/folders/Jing/media/c25ec5c6-bc6a-413c-a50b-ada95fac4ed2/2012-07-25_0221.png
  4. Server returns back image source URL. no idea!

Is there any possible way to get image url with Javascript or PHP?

2
  • Well, what process did you use to get the link ('real' one) that you did? Automate it. It's probably a trivial matter of webscraping, but we can't help you since you didn't provide much detail. Commented Jul 25, 2012 at 1:31
  • Are you saying that the url http://screencast.com/t/zxBzNNkcg redirects to url http://content.screencast.com/users/TT13/folders/Jing/media/c25ec5c6-bc6a-413c-a50b-ada95fac4ed2/2012-07-25_0221.png and you really want to programmatically determine what the resulting redirected URL is? Commented Jul 25, 2012 at 1:38

4 Answers 4

1

you could use Simple PHP DOM Parser to retrieve the image from the url without considering the url for as long as it contains and image inside, like so:

foreach($html->find('div[class=div-that-contain-the image]') as $div) {         
        foreach($div->find('img') as $img){     
            echo "<img src='" . $img->src . "'/>";          
        }

    }

That is my solution.

Sign up to request clarification or add additional context in comments.

Comments

0

You can retrieve the page containing the image using a DOM library like Query Path.

Using that you can extract the URL to the image.

So in your step 3:

  • Get source of shared screenshot page (maybe use file_get_contents)
  • Extract screenshot's image src, using Query Path.
  • Return image src URL to user

Comments

0

Yes. If you right click on the image and go Copy Image Location, you'll see it's http://content.screencast.com/users/TT13/folders/Jing/media/c25ec5c6-bc6a-413c-a50b-ada95fac4ed2/2012-07-25_0221.png

If you were to do it programmatically, you would use cURL and simplehtmldom.sourceforge.net to parse the outputed HTML for the actual link.

Comments

0

Javascript answer:

Will the output image always have the same class, embeddedObject?

If so, how about something like:

myVar = document.getElementsByClassName('embeddedObject');
myVar[0].getAttribute("src");

The myVar[0] reference of course assumes that there is only ever one image on the page with the embeddedObject class, otherwise you'd need to sort, or know which index to reference each time.

Also, this sadly doesn't seem to be supported in IE8 (which browser do you need to support?): http://caniuse.com/getelementsbyclassname

1 Comment

Where is starting of code? How to fetch whole HTML of page with javascript?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.