Author

Topic: Simple PHP Scraper (Read 1867 times)

legendary
Activity: 2940
Merit: 1333
May 24, 2013, 11:40:23 PM
#15
+1 - well, it worked for a bit!

Still works for me.  Smiley

In the same series, here's a script that will tell you what time it is:

Code:

print "21:40:51\n";

Inspired by the goon show.
hero member
Activity: 490
Merit: 500
May 24, 2013, 11:26:47 PM
#14
Here's my version.  It's quicker because it avoids using the network at all:

Code:

print "We are in maintenance. Please come back later\n";

+1 - well, it worked for a bit!
legendary
Activity: 2940
Merit: 1333
May 24, 2013, 11:00:02 PM
#13
Here's my version.  It's quicker because it avoids using the network at all:

Code:

print "We are in maintenance. Please come back later\n";
full member
Activity: 164
Merit: 100
May 04, 2013, 12:12:55 AM
#12
Oh, wow, I am bitcoiner now, thanks! Smiley
hero member
Activity: 490
Merit: 500
May 03, 2013, 07:00:23 PM
#11
Thank you both - tips sent.
full member
Activity: 188
Merit: 100
May 03, 2013, 09:31:56 AM
#10
I'd actually go with his, mine is REALLY quick and dirty, his is a little less so :p
hero member
Activity: 490
Merit: 500
May 03, 2013, 09:29:05 AM
#9
Good as well Smiley!
full member
Activity: 164
Merit: 100
May 03, 2013, 09:27:31 AM
#8
Oh, wow... Really genious... Here is my solution since I did it too:

Code:
  function get_max_price_from_table($table){                                                                                                   
    
$max_price 0;                                                                                                                            
    
$rows $table->getElementsByTagName('tr');                                                                                                
    for (
$i 1$i $rows->length$i++)                                                                                                     
      
$max_price max($rows->item($i)->getElementsByTagName('td')->item(0)->nodeValue$max_price);                                           
    return 
$max_price;                                                                                                                         
  }                                                                                                                                            
                                                                                                                                               
  
$html file_get_contents("http://exchange.bytecoin.in/");                                                                                   
  
$DOM = new DOMDocument;                                                                                                                      
  
$DOM->loadHTML($html);                                                                                                                       
  
$tables $DOM->getElementsByTagName('table');                                                                                               
  echo 
get_max_price_from_table($tables->item(1));                                                                                             
?>

Just in case if you decide to tip: 1Hn7xud8i8pn7WSTNmHzjYe7gLz1XmpTQH Smiley
full member
Activity: 188
Merit: 100
May 03, 2013, 09:20:16 AM
#7
Sure, if you like. Just note that if the page changes format (ie. more tags, etc get inserted before the buy price), that quick grab will break. You'd have to change the array number to match the change.

1HcNqP6uzqEcmsNe4uDu38qDWXonU2z6ci
hero member
Activity: 490
Merit: 500
May 03, 2013, 09:14:45 AM
#6
Genius - can I send you a small tip?
full member
Activity: 188
Merit: 100
May 03, 2013, 09:07:22 AM
#5

$url = "http://exchange.bytecoin.in/";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);

preg_match_all("|<[^>]+>(.*)]+>|U", $curl_scraped_page, $out);

echo "Max buy: " . $out[1][10] . "\n";

?>
full member
Activity: 164
Merit: 100
May 03, 2013, 08:42:19 AM
#4
Sounds simple, I will do it.
hero member
Activity: 490
Merit: 500
May 03, 2013, 08:40:11 AM
#3
Nope - just get the price.  SImple scraper.
full member
Activity: 164
Merit: 100
May 03, 2013, 08:21:33 AM
#2
Should it consider amount of bte to be converted?
hero member
Activity: 490
Merit: 500
May 03, 2013, 07:33:34 AM
#1
I need a quick and dirty PHP script written that scrapes the highest price for converting Bytecoin into BTC as posted here - http://exchange.bytecoin.in/.

Any takers?
Jump to: