473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Read another websites source code with php

196 100+
Hey im new to php, anyway i have a website which will contain some information and will be updated regurly but rather than edit about 30 other websites as well for just the single page, i want to retrieve the source code of one website and view in all the others.

So far iv worked out how to output html code with php e.g.

Expand|Select|Wrap|Line Numbers
  1. $source = "<a href='http://www.google.com'> a link1</a>";
  2. echo $source;
  3.  
Any how i need to find out how to access a website and read its source code so that i can print it out on all other websites.

Hope this is clear enough if you need me to explain anymore ask;

Thanks for any help. it is greatly appreciated.
Apr 26 '08 #1
6 1869
chazzy69
196 100+
Iv found some code that may achieve this but i get some errors that i can figure out -

Expand|Select|Wrap|Line Numbers
  1. $source=fopen("http://www.mywebsite.com/index.html", "r") or exit("Unable to open website!");
  2.  
  3. //Output a line of the file until the end is reached
  4.  
  5. while(!feof($file))
  6.   {
  7.   echo fgets($file);
  8.   }
  9.  
  10. fclose($source);
  11.  
The errors are - (test.php is php file i using to code in)

Warning: fopen(http://www.mywebsite.com/index.html): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/content/d/a/t/*******/html/mywebsite/test.php on line 20
Apr 26 '08 #2
chazzy69
196 100+
Don't Worry i figured out the problem or rather what works, thanks anyway
Apr 27 '08 #3
ronverdonk
4,258 Expert 4TB
Do you want to share your solution with our members?

Ronald
Apr 27 '08 #4
chazzy69
196 100+
It was terrible simple i had just forgot to name a varible the right thing

Expand|Select|Wrap|Line Numbers
  1. $source=fopen("http://www.mywebsite.com/index.html", "r") or exit("Unable to open website!");
  2.  
  3.  
  4. while(!feof($source))
  5.   {
  6.   echo fgets($source);
  7.   }
  8.  
  9. fclose($source);
  10.  
And that fixed the problem i was having
Apr 27 '08 #5
ronverdonk
4,258 Expert 4TB
Thanks for this. see you around.

Ronald
Apr 28 '08 #6
rpnew
188 100+
Hi,
If i'm not wrong you can get the same output with following as well
[PHP]
$tempcontent = file_get_contents('http://search.yahoo.com/');
echo $tempcontent;
[/PHP]

Regards,
RP
Apr 29 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Colin Jack | last post by:
Hi, I was wondering if anyone could suggest Websites with usable source code on them...I've tried PlanetSourceCode.com but i've found the Website flakey so am looking for another one to use. ...
1
by: Kenny | last post by:
If MapPath is the way to go, then how can I reference the desired folder as relative to the current site's root (I don't want to hard-code the path from the C:\root folder). FWIW the logic that...
1
by: Dean R. Henderson | last post by:
I setup FormsAuthentication on a couple websites where it has been working as expected for a long time. I used this code to setup the same type of authentication on a new website I am working on...
5
by: anon | last post by:
I am relatively new to vb.net having used vb4/5/6 for a while, and wonder if there are any good websites with sample code. I have located a couple, but their samples are limited. I would...
7
by: VB Programmer | last post by:
I am an independent ASP.NET/Flash developer. I currently have about 15 ASP.NET, Flash, and mixed websites that I created and manage. Because of various factors I am thinking about selling the...
0
by: CNN_news | last post by:
I would like to run multiple instances of TYPO3 (a cms written in PHP) on a single server. You can run multiple websites in two methods: multisite or multiple instances. In multiple...
1
by: SK | last post by:
Hello My company develops as well as hosts .NET applications. The applications have been developed using .NET framework 1.1 and C#. We recently moved the websites from a Win2K/IIS 5.0 environment...
9
by: CoreyWhite | last post by:
I have a vision for webservers, like apache, which drive websites online. Html and PHP are basically just templates that webservers *USE*. If we want to be real geniuses then we need to code our...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.