As we post any url on facebook, it shows its meta-data(title, decription and thumbnail image), How can we achieve same thing in php or scripting language(javascript/jquery).
I believe, Facebook simply parses the html code of the Website behind the link and looks for <img /> tags. You can then choose any of the found images as picture for your link.
In PHP, you would fetch the websites HTML source via
$html = file_get_contents('http://...');
Then use regular expressions to find those <img /> tags.
you make an ajax hit to your server sending the URL
on the server side, get the url
parse it, extract the relevant info
send back the response as a either as JSON and parse it on the client side, either straight as HTML
There is a good plugin that can be used as a headstart.
It does not fetch the image, but it's a start if you want to implement your own
http://www.webinfopedia.com/extract-meta-data-from-url-using-php.html
Related
I am trying to grab an image on my WebNative Xinet portal. When i use the method i am using right now: I get an image back, but i also get all the HTML with it to display the image. This is what i am using to grab the image right now:
GETIMAGE.php?type=small&path=/Images/myimage.png
This is kind of working. The issue with this is that it returns a complete HTML document with the image tags in it displaying the image.
How is it possible to get the raw image back with no HTML included? My main objective is to grab the image and encode it to base64 to be displayed in an e-mail.
That request should absolutely be giving you an HTTP response with an image payload.
I'm assuming you're using cURL to speak with Portal. Did you authenticate with server before making the GETIMAGE.php request? If so, are you including the session ID cookie in your GETIMAGE.php request?
EDIT: I saw your other post and it looks exactly like the auto-generated code Chrome shows in its DOM inspector. Are you sure you're getting HTML from that URL? I'm staring at the source and I can't find anywhere where it emits HTML.
Now, I am encountering some difficulties when I have to scan or crawl a video URL link. This web page is using the Flash-based technology to embed the video and stream video.
In order to understand more clearly, this is a link example:
http://vnexpress.net/gl/the-gioi/tu-lieu/2012/11/bai-phat-bieu-thua-nhan-that-bai-cua-romney/
The above link has below content (HTML code for Flash embedded video):
<div id="flashContent" style="text-align:center;width:100%;">
<span id="FlashPlayer79237" class="Normal" align="center">Bạn cần cài Flash Player để xem được Clip này.</span>
</div>
In this above article, there is a above video. However, when I tried to scan or crawl the content, the video could not run properly (because it could not load correct video link) and only show Install Flash Player plugin words (Certainly, the real web page needs to run some Javascript script or Flash script to obtain the real video link and stream this video for users)
Therefore, how can I render Flash and Javascript script through PHP or ASP.NET or Java? How can I get the correct video link when I crawl the web page? In this case, how can I obtain the correct Flash embedded video (HTML code)?
Thank you so much.
Before I answer, I want to make a note that if you need this information to do anything shady... please don't.
Disclaimer aside, for that particular site it is relatively easy.
The flashvars param (which is probably put there by Javascript) contains a value called xmlPath, which is a url encoded path (relative to their domain name). If you grab that and decode it, you get something like:
/Service/FlashVideo/PlayListVideoPage.asp?id=79237&f=108&t=1
which points to
http://vnexpress.net/Service/FlashVideo/PlayListVideoPage.asp?id=79237&f=108&t=1
If you read that, it's an XML file which contains the URL of the actual video.
I'm not quite sure where that value is generated from. If you needed to do this fully server-side, you could use a headless browser to process it.
I want to get FLV file url of the webpage with automation, is it possible? because that site has no autoplay, when i use GetFLV i get the url on when i press play button, i need to get url in php code'automatically, How to do it?
Retrieve the HTML of the page (using a library such as cURL)
Parse the retrieved HTML (using a library such as the PHP DOM)
Extract the relevant URL from the DOM tree
It is possible the URL was generated via JavaScript, in which case you'll also need to run a JS interpreter or close facsimile thereof.
P.S. - remember to check that doing this does not violate the web site's terms of service.
I have standard text links which all say "Full View". When clicked these links send out php in this form: http://mysite.com/fullview.php?myimage=30
Basically there's thumbnailed images and text links that say full view. I'd like for fullview.php to capture the myimage variable, and display it as a full sized image. Meaning, a blank page (fullview.php) displaying the image. Sounds likes javascript to me.
How do you put the javascript into fullview.php to capture the variable and display it as a full sized image?
Thanks for any help,
Darrell
php is server side script
javascript is client side script
so displaying a web page to a user first is executed php and result is send to client. After he receive it then javascript is executed
HTH
Ivo Stoykov
You just need to read the query parameters. In fullview.php you can use
$myimage = $_GET['myimage']; to capture this variable. And then can use it accordingly.
i read the meta tags from a PHP script that read the url convert it to html and then read the tags and title .................for this no problem but the problem is i wants to read only the text from html...............
for Example when you put a link on facebook you can see that i read's your Title and some text from your webpage url.
like the google does while search the web page.
i wants to know that how can i write a script that work like a facebook book mark.........
Use DOMDocument::loadHTML