[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 815
  • Last Modified:

Ho do you pull data into your webpage from another website

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
matthewdacruz
Asked:
matthewdacruz
  • 4
  • 4
  • 4
  • +1
1 Solution
 
waygoodCommented:
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
 
waygoodCommented:
BUT if you wanted to retrieve the webpage to process the information somehow, I would use CURL or FILE
0
 
simonkinCommented:
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
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
matthewdacruzAuthor Commented:
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
 
waygoodCommented:
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
 
waygoodCommented:
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
 
siliconbritCommented:

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
 
matthewdacruzAuthor Commented:
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
 
siliconbritCommented:
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
 
matthewdacruzAuthor Commented:
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
 
siliconbritCommented:

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
 
siliconbritCommented:

ROTFL - Not even a points split for saving your a%%
0
 
matthewdacruzAuthor Commented:
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

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 4
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now