Solved

Ho do you pull data into your webpage from another website

Posted on 2007-11-21
13
798 Views
Last Modified: 2008-12-20
Hi Experts

I am wanting to pull data straignt into a text area from another website based on a url. IS this possible and how would I go about doing this.

Here is the url that gets the data
http://www.nethouseprices.com/index.php?con=sold_prices_street&cCode=SC&postcode=ml38jh

Ideally i will pull the postcode from a database in inject it into the string but how do I get the data back to my page. Would I use a GET?

Some guidance on this would be great

Thanks

MDC
0
Comment
Question by:matthewdacruz
  • 4
  • 4
  • 4
  • +1
13 Comments
 
LVL 9

Expert Comment

by:waygood
ID: 20327909
You could just use an iframe and put the required postcode into the required URL

<?php

$postcode="ML38JH";

?>
 

<iframe src="http://www.nethouseprices.com/index.php?con=sold_prices_street&cCode=SC&postcode=<?php echo $postcode; ?>" width="200" height="200"><iframe>

Open in new window

0
 
LVL 9

Expert Comment

by:waygood
ID: 20327931
BUT if you wanted to retrieve the webpage to process the information somehow, I would use CURL or FILE
0
 
LVL 4

Expert Comment

by:simonkin
ID: 20327988
Here's a cUrl function to get you along the way....


<?php
 

	// Initialise cURL

	$ch = curl_init();

	

	// Set a timeout - set to zero for no timeout

	$timeout = 5;

	

	// Set the url to crawl

	curl_setopt ($ch, CURLOPT_URL, 'http://www.domain.com');

	

	// Return the output

	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

	

	// Pass the timeout to cURL

	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

	

	// Gather the contents

	$file_contents = curl_exec($ch);

	

	// Stop cURL

	curl_close($ch);

	

	// Display the output

	echo $file_contents;

?>

Open in new window

0
 

Author Comment

by:matthewdacruz
ID: 20328100
I am new to php so please excuse the lack of knowledge.

How will I apply the function to a text area in a form


<?php

 

	// Initialise cURL

	$ch = curl_init();

	

	// Set a timeout - set to zero for no timeout

	$timeout = 5;

	

	// Set the url to crawl

	curl_setopt ($ch, CURLOPT_URL, 'http://www.nethouseprices.com/index.php?con=sold_prices_street&cCode=SC&postcode=ml38jh');

	

	// Return the output

	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

	

	// Pass the timeout to cURL

	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

	

	// Gather the contents

	$file_contents = curl_exec($ch);

	

	// Stop cURL

	curl_close($ch);

	

	// Display the output

	echo $file_contents;

?>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>
 

<body>

<form id="form1" name="form1" method="post" action="">

  <p>

    <textarea name="datafield" id="datafield" cols="45" rows="5"></textarea>

  </p>

  <p>

    <input type="submit" name="submit" id="submit" value="Submit" />

    </p>

</form>

</body>

</html>

Open in new window

0
 
LVL 9

Expert Comment

by:waygood
ID: 20328189
1.remove echo $file_contents;
2.put it in between your textarea tags

ie
<textarea name="datafield" id="datafield" cols="45" rows="5"><?php echo htmlentites($file_contents); ?></textarea>

WARNING: This will put the html code only in your text box. It will not show the webpage
0
 
LVL 9

Accepted Solution

by:
waygood earned 500 total points
ID: 20328213
sorry missed the second "i" in htmlentities

You may want to lookup WYSIWYG editors if you want the webpage displayed. BUT this will show code as if it was on your site, so images will be broken and references to other pages such as links and stylesheets will also not work. This is why I suggested iframe first
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Expert Comment

by:siliconbrit
ID: 20328237

Sorry to be a pain, but we are unable to help you in any way that might breach the copyright or intellectual property of another website.  This is in the Experts Exchange Membership Guidelines.

You are asking for help to use data from the www.nethouses.com website.  Their own terms and conditions state at (http://www.nethouseprices.com/index.php?con=terms#6_your)

(c) Nethouseprices.com may only be accessed manually. The use of automated agents, robots, or automated software, other than search engine spiders, to view the site is specifically forbidden.

Before any more experts assist you with this, can you confirm your permission to do so?

Thanks.
0
 

Author Comment

by:matthewdacruz
ID: 20329327
Hi Guys

I just used nethouse prices as an example. I do aplogise if this has caused and issue. It was the principle of extracting data that I am trying to figure out how to do. To answer siliconbrit's query the truth is I had not got permission from nethouse, it was just a site i currently was on when the thought came to mine.

Will we still be able to continue with question or should i close it?

Regards

MDC
0
 
LVL 11

Expert Comment

by:siliconbrit
ID: 20330054
To be honest, it's up to the moderator for this zone, or if an expert is satisfied that this was used as an "example", then they may wish to continue.

Having said that, I would advise you to be careful to get permission from any third-party site when you want to use their data on your own site, and they don't explicitly provide open permission for you to do so.  Even blog sites and rss feeds often have terms associated with them.

Companies are becoming increasingly aware that copyright infringement cases almost always settle in favour of the data owner, and I know of several people who have been hit with bills of over £100,000 in the UK merely for sub-framing sites within their own - exactly the technique that is being suggested by the experts in this question.  Please be careful.
0
 

Author Comment

by:matthewdacruz
ID: 20330089
Hi Thanks for the advise. It will be taken seriously. I would prefer to close the question as not to get anyone in trouble.

Waygood had given the best answer and I will award waygood the points. Silconbrit thanks for the advice and It is appreciated.

MDC
0
 
LVL 11

Expert Comment

by:siliconbrit
ID: 20330090

One more note.  The experts-exchange site is indexed by the major search engines every day, and is specifically designed to make sure that the text of questions is exposed to the search engines, and is optimised to achieve a high ranking.  Within a day or so, searching for the term "nethouseprices.com" will likely show this page in Google search results.
0
 
LVL 11

Expert Comment

by:siliconbrit
ID: 20330128

ROTFL - Not even a points split for saving your a%%
0
 

Author Comment

by:matthewdacruz
ID: 20330254
Sorry Dude
'No Offence' meant but as I had stated I used the site as an example to demonstarte the url string. It may aswell have been http://www.whatever.com/index.php?con=xxx_street&cCode=SC&postcode=ml38jh. The reason why I use Experts exchange is to learn and improve my ability. Not to rip off other peoples content.

I appreciate your point of view, advise and goodwill in passing on the warning but your response at the same time did not provide a solution to my question but infact put a halt on all responses that where helping me figure out my problem and learn how to pull data between sites; so this is the reason why I awarded waygood the points as he provided the me the most relevant information, help & answer to my question I asked. If I had asked 'will I get into trouble for pulling content off another site without permission' You would have be awarded the full prize.

Thanks

MDC
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP/Magento not logging 2 36
WordPress Themes 10 34
How do I put a session for a radio button? 4 14
echo time from sql to input type="time" 9 19
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now