Jump to content

Echo external websites HTML source code


seany123

Recommended Posts

i dont see how it gets the source.

 

Did you read the manual?  It explains how it works and gives you multiple examples of how to use it.  There are other options depending on exactly what you want to do.

Link to comment
Share on other sites

<?php

$homepage = file_get_contents('http://www.example.com/');

echo $homepage;

?>

 

that doesnt work... i actually want the source code displayed not the html.

 

what im expecting is lines of html code.

 

 

<?php
$homepage = file_get_contents('http://www.google.com/');
echo $homepage;
?>

 

shows the search bar and buttons, but what i wanna see is the source, the inputs etc

Link to comment
Share on other sites

that doesnt work... i actually want the source code displayed not the html.

 

what im expecting is lines of html code.

 

You just contradicted yourself.  What exactly are you trying to see?  You cannot see server side code, only client side.

Link to comment
Share on other sites

$addr = 'http://google.com';
$fp   = file_get_contents($addr);

echo stripslashes(htmlentities($fp, ENT_QUOTES));

 

 

thats working brilliantly, now i need help with one more thing.

 

i want to search for 2 things inside the source code.

 

first thing is a image... i was thinking of somehow making a search for starting in http:// and ending in .jpg

 

second i need to find the same thing for a .avi file

 

starting in http:// and ending in .avi

 

they need to then be set as variables to i can use them with my db.

Link to comment
Share on other sites

the only reason "that works brilliantly" is that you can now see the HTML-formatted HTML in your browser. however, what you are seeing is no longer the same as the source code you see on the website. Maq is correct: the previous code is what you want.

 

for some reason the other code didn't show the source, the current code may not show the true source but it does show the part of the code I need.

 

now i just gotta search for the two links in the code.

 

what would be the most efficient way of doing this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.