473,761 Members | 6,993 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read and display content from URL

exoskeleton
104 New Member
hi guyz..please help me dear experts. my boss wants to display something from other sites in our page. can someone who have a kind hearted to help me deal with this? please...

i used fopen() but it displays the code of the site...i only want to display the real output. this means what you see exactly on the IE or other explorers.

is this possible? for example i have :

http://www.sample.com/a.php

and the output is "hello world" then i want that output display in other page like http://www.xample.com/b.php

please help...me...

TIA
Mar 31 '07 #1
6 23897
Nert
64 New Member
i used fopen() but it displays the code of the site...i only want to display the real output. this means what you see exactly on the IE or other explorers.

is this possible? for example i have :

http://www.sample.com/a.php

and the output is "hello world" then i want that output display in other page like http://www.xample.com/b.php

please help...me...

TIA
Hi exoskeleton..,

Uhmmn i'm kinda confuse with your problem.., but try the include function in PHP, it might help you to solve your problem.

for example:
you want to display the output of the page http://www.sample.com/a.php to the page http://www.xample.com/b.php

from the coding of the page b.php you just put something like this;
[PHP]<?php
// include('path of a certain page you want to include');
include('a.php' );
?>[/PHP]

hope that helps you.


--nert (^_^)
Mar 31 '07 #2
exoskeleton
104 New Member
Hi exoskeleton..,

Uhmmn i'm kinda confuse with your problem.., but try the include function in PHP, it might help you to solve your problem.

for example:
you want to display the output of the page http://www.sample.com/a.php to the page http://www.xample.com/b.php

from the coding of the page b.php you just put something like this;
[PHP]<?php
// include('path of a certain page you want to include');
include('a.php' );
?>[/PHP]

hope that helps you.


--nert (^_^)
thank you sir...but not that kind! it still displays the <HTML>....blah. .blah...

i only want to display the output...the "HELLO WORLD" only
Apr 11 '07 #3
code green
1,726 Recognized Expert Top Contributor
If you 'include' a file within php and that file has no php braces then the file is output as a HTML file. You should not see the tags.
Apr 11 '07 #4
bucabay
18 New Member
hi guyz..please help me dear experts. my boss wants to display something from other sites in our page. can someone who have a kind hearted to help me deal with this? please...

i used fopen() but it displays the code of the site...i only want to display the real output. this means what you see exactly on the IE or other explorers.

is this possible? for example i have :

http://www.sample.com/a.php

and the output is "hello world" then i want that output display in other page like http://www.xample.com/b.php

please help...me...

TIA
If you post a bit of your code it would be easier to figure out the problem.

What you're trying to do I believe is "screen scrape" the contents of another webpage and display it on your webpage?

If you do something like:

[PHP]echo file_get_conten ts("http://www.sample.com/a.php");[/PHP]

You will echo the whole HTML of the page http://www.sample.com/a.php from your php script.

IF you do:

include("http://www.sample.com/a.php");

You will get the exact same thing. This is because you are including a file from HTTP and the include() function will first register a wrapper for the HTTP stream and "download" the page "http://www.sample.com/a.php" just as if you made a HTTP connection. So you will receive the resulting HTML after the server at http://www.sample.com/ parses "a.php" and not the PHP code.

This is different from including a file in your own directory, as you will be including the raw PHP code.

Usually if you're going to screen scrape a webpage then you only want certain parts of the HTML. You can get this data using regular expressions or you could parse the HTML into PHP Objects using a XML parsing standard such as DOM or SAX etc. (These are built into most PHP versions)

Example of using regex to get the HTML in between <body> and </body> in an HTML page:


[PHP]
$cotnent = file_get_conten ts("http://www.sample.com/a.php");

preg_match("/<body(.*?)>(.+? )<\/body>/s", $content, $matches);

echo $matches[2];

[/PHP]
Apr 11 '07 #5
exoskeleton
104 New Member
If you post a bit of your code it would be easier to figure out the problem.

What you're trying to do I believe is "screen scrape" the contents of another webpage and display it on your webpage?

If you do something like:

[PHP]echo file_get_conten ts("http://www.sample.com/a.php");[/PHP]

You will echo the whole HTML of the page http://www.sample.com/a.php from your php script.

IF you do:

include("http://www.sample.com/a.php");

You will get the exact same thing. This is because you are including a file from HTTP and the include() function will first register a wrapper for the HTTP stream and "download" the page "http://www.sample.com/a.php" just as if you made a HTTP connection. So you will receive the resulting HTML after the server at http://www.sample.com/ parses "a.php" and not the PHP code.

This is different from including a file in your own directory, as you will be including the raw PHP code.

Usually if you're going to screen scrape a webpage then you only want certain parts of the HTML. You can get this data using regular expressions or you could parse the HTML into PHP Objects using a XML parsing standard such as DOM or SAX etc. (These are built into most PHP versions)

Example of using regex to get the HTML in between <body> and </body> in an HTML page:


[PHP]
$cotnent = file_get_conten ts("http://www.sample.com/a.php");

preg_match("/<body(.*?)>(.+? )<\/body>/s", $content, $matches);

echo $matches[2];

[/PHP]

Thank you sir...i'll try you code!
Apr 12 '07 #6
pentrac
2 New Member
Well...I am not sure whether the problem I am facing is the same as this. I am trying to read the content of a HTML file, then save the details into database.

Lets say this is the HTML output:

Name : pentrac
Email : pentrac@yahoo.c om

I am trying to save 'pentrac' and 'pentrac@yahoo. com' into a table in mysql. I don't really know if we can do that with PHP. Well...I hope some of you can help me with this...

Thanks in advance... :)
Apr 19 '07 #7

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

Similar topics

2
1326
by: Ing. Rajesh Kumar | last post by:
Hi everybody I have a problem reading the content of a cell. When i use AutogenerateColumns = True or when i use <asp:BoundColumn DataField="COLUMN1" HeaderText="COLUMN1"/> then i can simply read the content of a cell in the OnItemDataBound method using the following code : For j = 0 To DT.Columns.Count - 1 If e.Item.Cells(j).Text = "something" Then Do Something Next Now i changed some columns to template columns as follows :...
0
1523
by: VeeraLakshmi | last post by:
I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.If the HTTP header contains Content-Length,am getting the content length as below: public class HTTPResponseReader extends HTTPMessageReader { String statusCode; public HTTPResponseReader(InputStream istream) throws IOException, NoSuchElementException { BufferedInputStream distream = new...
2
5866
by: VeeraLakshmi | last post by:
Can anybody tell me how to get or read the value of transfer encoding. I got the HTTP Response header as "Transfer-Encoding: chunked".But i can't get the chunk size or the chunked data. Without getting those details i cant read the content of the site.If Content-Length is in the HTTP header,i can read upto that length.But in this Transfer-Encoding case,i cant know any other details except the value "chunked".So suggest me to read the content...
2
1461
by: ernesto | last post by:
I've read that search engines do not read flash content, and meta tags are not supported by many of the main search engines anymore. Can anyone tell me if there is a way to work around it, so my all flash website can be seen with search engines like google or yahoo?
1
3846
by: bogie | last post by:
Hello I have some problem with psqldump. I need to read some table from my postgresql backup (psqldump file). is there any body can help me, how can i read this psqldump, or is there any way to transfer this file to text file or something so i can read the content of this file. can any body show me which command should i use ?, if there is an example it would be better. Thank you very much. bogie
4
1404
by: Ravigandha | last post by:
Hello everyone, I want to read the content of the mail from outlook express. then send that content to other mail. First is it possible to read the content of mail in PHP? waiting for ur comments
1
1463
by: soni2926 | last post by:
hi, we're building a site which will have common pages for different users, but certain sections will show different content based on the membership of the logged in user, like admin, manager, developer, tester, etc... any advise on what's the best way to handle those sections? basically we're going to show a gridview on data in them, just different data depending on who's logged in. Is it better to have a panel and populate that with...
3
2488
by: Man4ish | last post by:
Hi, I am working on one application in which i need to read the contents of one file test.tar.gz which has 50000 files. I know the names of files inside but i don't want to unzip it. I want C++ program to read the file test.tar.gz and read the content of one of the file ( let' day sample1.txt ), so that it can be very fast. How can i do it? Please help. Thanks
8
1838
by: rohanit46 | last post by:
i need to read xml content from a web service onto a local machine and parse the data using javascript. While using XMLHttpRequest, it allows me to access xml content from anywhere on local machine. But i m not getting a clue as to how to access the content from a service Any help appreciated
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9923
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.