PHP Script Question

SpaceshipSpaceship
Watch

Raf

Established Member
Impact
5
Hi there, I was wondering if anyone knows about any scripts that can get news and images from another news site like Yahoo or Google without having the other sites layout for example (content grabbing). This can be done in RSS/XML I persume but does anyone know where I can find scripts in PHP. Please post here. Thanks. :tu:
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
never seen a php script available like that but probably hotscripts is your best bet, other than that you can find a url open it using the fopen function

you would have to define the parts of the page you want to display but thats pretty much all you have to do. maybe when i get time ill write a tutorial on this
 
0
•••
Do you have any examples of how to do this or any URL's that I could go to. I have gone to HotScripts already and havent found much, well there was one but it just had a whole page included and it was commercial.
 
0
•••
PHP:
<?php
  // choose stock to look at
  $symbol='AMZN';
  echo "<h1>Stock Quote for $symbol</h1>";

  $theurl='http://www.amex.com/equities/listCmp/EqLCDetQuote.jsp?Product_Symbol=AMZN';


  if (!($fp = fopen($theurl, 'r')))
  {
    echo 'Could not open URL';
    exit;
  }
  $contents = fread($fp, 1000000);
  fclose($fp);

  //echo $contents;

  // find the part of the page we want and output it
  $pattern = "(\\\$[0-9 ]+\\.[0-9]+)";
  if (eregi($pattern, $contents, $quote))
  { 
    echo "$symbol was last sold at: ";
    echo $quote[1];
  } else 
  {
    echo 'No quote available';
  };

  // acknowledge source
  echo '<br />'
       .'This information retrieved from <br />'
       ."<a href=\"$theurl\">$theurl</a><br />"
       .'on '.(date('l jS F Y g:i a T'));
?>

Hope that helps.
 
0
•••
Thanks for the code snippet Elefekt, but how would you be able to make it take out what you want. For example lets try Yahoo News, how would to be able to take out the layout of their site but include the images and etc.
 
0
•••
you have to define a pattern ill try to think of a good way to explain it (i am a bad teacher)
 
0
•••
Well I know in excel you can import tables from certain sites (my dad does this to analyze hockey stats for his pool). I'm sure you could do the same thing with PHP but I haven't looked for something that does this - just an idea.

Ex: In Excel you sepcify the website and the table number and excel returns that table. so if you specify table #6 then excel goes to that page, finds the 6th <table> tag and returns the contents of that table.
 
0
•••
This can be done, as Elefekt pointed out, by pattern matching until you get to the correct part of the Yahoo/Gogle HTML page. However, I wouldn't advise doing this for two reasons:

1. Yahoo and Google change their page formats one in a while, and each time they do you'll have to rewrite your php scripts.

2. I believe this would go against Yahoo and Google's terms of service to just grab their content and display it on your site as your own. If your site becomes somewhat popular, Yahoo nand Google *will* quickly notice because your scripts will be doing so many lookups. When they do notice, they might cut off your IP address from any access.

The best way to do this is through RSS/XML, but you need to have access to their RSS/XML feeds, which I assume isn't public knowledge and probably requires some kind of authentication.
 
0
•••
Well I know how to use RSS/XML but I dont know how to get the article and put it on your own site. Thats kinda what Im trying to get to.
 
0
•••
are you thinking of having your site automatically update if yahoo updates? something like that?

i cant think of an easier way to explain it in php

even if i could you would be better off getting feeds because stealing content is illegal
 
0
•••
Yeah I understand what you mean Elefekt, but I was talking more in general about sites that give you permission. For example I know that there is a commercial script known as phpCNN which takes content from CNN News. Im not sure if this is legal or not but its there. Can you show me another snippet of another page cutting out the other things around it. Thanks.
 
0
•••
Appraise.net

We're social

Spaceship
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back