Bitcoin Forum
June 16, 2024, 07:31:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Simple PHP Scraper  (Read 1842 times)
sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 03, 2013, 12:33:34 PM
 #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?
bitcoinator
Full Member
***
Offline Offline

Activity: 164
Merit: 100


View Profile
May 03, 2013, 01:21:33 PM
 #2

Should it consider amount of bte to be converted?
sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 03, 2013, 01:40:11 PM
 #3

Nope - just get the price.  SImple scraper.
bitcoinator
Full Member
***
Offline Offline

Activity: 164
Merit: 100


View Profile
May 03, 2013, 01:42:19 PM
 #4

Sounds simple, I will do it.
Chemicalbro
Full Member
***
Offline Offline

Activity: 188
Merit: 100



View Profile
May 03, 2013, 02:07:22 PM
 #5

<?php

$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";

?>

Vircurex Exchange BTC/LTC/NMC
sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 03, 2013, 02:14:45 PM
 #6

Genius - can I send you a small tip?
Chemicalbro
Full Member
***
Offline Offline

Activity: 188
Merit: 100



View Profile
May 03, 2013, 02:20:16 PM
 #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

Vircurex Exchange BTC/LTC/NMC
bitcoinator
Full Member
***
Offline Offline

Activity: 164
Merit: 100


View Profile
May 03, 2013, 02:27:31 PM
 #8

Oh, wow... Really genious... Here is my solution since I did it too:

Code:
<?php                                                                                                                                          
  
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
sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 03, 2013, 02:29:05 PM
 #9

Good as well Smiley!
Chemicalbro
Full Member
***
Offline Offline

Activity: 188
Merit: 100



View Profile
May 03, 2013, 02:31:56 PM
 #10

I'd actually go with his, mine is REALLY quick and dirty, his is a little less so :p

Vircurex Exchange BTC/LTC/NMC
sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 04, 2013, 12:00:23 AM
 #11

Thank you both - tips sent.
bitcoinator
Full Member
***
Offline Offline

Activity: 164
Merit: 100


View Profile
May 04, 2013, 05:12:55 AM
 #12

Oh, wow, I am bitcoiner now, thanks! Smiley
dooglus
Legendary
*
Offline Offline

Activity: 2940
Merit: 1330



View Profile
May 25, 2013, 04:00:02 AM
 #13

Here's my version.  It's quicker because it avoids using the network at all:

Code:
<?php

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

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
sal002 (OP)
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile WWW
May 25, 2013, 04:26:47 AM
 #14

Here's my version.  It's quicker because it avoids using the network at all:

Code:
<?php

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

+1 - well, it worked for a bit!
dooglus
Legendary
*
Offline Offline

Activity: 2940
Merit: 1330



View Profile
May 25, 2013, 04:40:23 AM
 #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:
<?php

print "21:40:51\n";

Inspired by the goon show.

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!