Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

regular expression

Posted on 2010-11-18
11
Medium Priority
?
280 Views
Last Modified: 2012-05-10
hi guys., i am building currency converter with php. i need to scrape of the currency codes and rates from xe.com or bloomberg website. has any one got any idea on which php script can scrape the data and output the currency codes and rates?

thanks in advance
0
Comment
Question by:peterade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 51

Expert Comment

by:Steve Bink
ID: 34171356
Why reinvent the wheel?  Have you tried:

http://www.google.com/#q=currency+converter+web+service

0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 34172206
Why don't use this: http://www.xe.com/ucc/#? Here you can customize it to include it in your site: http://www.xe.com/ucc/customize.php

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34172675
Not sure about Bloomberg, but you might want to see this page before you spend much time on the project:
http://www.xe.com/errors/noautoextract.htm
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34172781
@Ray_Paseur

Hmm...  I did not realize that. I retract my previous comment then. Thank you Ray_Paseur for keeping me honest  :)
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1500 total points
ID: 34172814
Yeah, they even have comments in the HTML beside each currency name about prohibited access.  I found that you can get around their checking algorithm by masking with CURL, but that still violates their TOS, so in the spirit of honesty I will not do that.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34173109
Thank you _alias99  :)
0
 

Author Closing Comment

by:peterade
ID: 34198696
-
0
 

Author Comment

by:peterade
ID: 34338707
hi guys . i am building a currency converter with php. i managed to scrape the currency rates from bloomberg. i have got an array of rates outputed. can someone teach me how to input the array of rates into a database.

steps
i1) i know how to connect to a database
2) select a the table.
3) i need the script to store the array data into a table.
pls help me guys. its really urgent!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0
 

Author Comment

by:peterade
ID: 34338770

class config {


    //variable declarations

    var $content;
    var $exch_rates = array();
    var $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_table;

    // getting and scraping data from bloomberg
    function config() {
        $this->mysql_host = 'localhost';
        $this->mysql_user = 'root';
        $this->mysql_pass = 'code';
        $this->mysql_db = 'converter';
        $this->mysql_table = 'currencies';
        $this->exch_rates = $rates;
        $this->content = $file;
        $this->rates = $exchangerates;



        if (!$file = file_get_contents('http://www.bloomberg.com/personal-finance/calculators/currency-converter')) {
            // generate error request from xml file
            echo'error';
        } else {
            $cur = array('ADP', 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'ATS', 'AUD', 'AWG', 'AZM', 'ATS', 'AZM', 'AZN', 'BAM', 'BBD', 'BDT'
                , 'BEF', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BWP', 'BYR', 'BZD', 'CAD', 'CDF', 'CHF', 'CLF', 'CLP', 'CNY', 'COP',
                'CRC', 'CUP', 'CVE', 'CYP', 'CZK', 'DEM', 'DJF', 'DKK', 'DOP', 'DZD', 'ECS', 'EEK', 'EGP', 'ERN', 'ESP', 'ETB', 'EUR', 'FIM', 'FJD', 'FRF',
                'GBP', 'GEL', 'GHC', 'GHS', 'GIP', 'GMD', 'GNF', 'GRD', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'IEP', 'ILS', 'INR', 'IQD',
                'IRR', 'ISK', 'ITL', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP'
                , 'LKR', 'LRD', 'LSL', 'LTL', 'LUF', 'LVL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MTL', 'MUR', 'MVR',
                'MWK', 'MXN', 'MYR', 'MZM', 'MZN', 'NAD', 'NGN', 'NIO', 'NLG', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK'
                , 'PHP', 'PKR', 'PLN', 'PTE', 'PYG', 'QAR', 'ROL', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SDR', 'SEK', 'SGD', 'SHP', 'SIT',
                'SKK', 'SLL', 'SOS', 'SRD', 'SRG', 'STD', 'SVC', 'SYP', 'SZL', 'THB', 'THO', 'TJS', 'TMM', 'TND', 'TOP', 'TRL'
                , 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UDI', 'UGX', 'USD', 'UYU', 'UZS', 'VEB', 'VEF', 'VND', 'VUV', 'WST', 'XAF', 'XAG', 'XAU', 'XCD', 'XEU'
                , 'XOF', 'XPD', 'XPF', 'XPT', 'YER', 'ZAR', 'ZMK', 'ZWD', 'ZWR');




            for ($i = 0; $i < count($cur); $i++) {
                preg_match("/price\['$cur[$i]:\S*\s=\s(\S*);/", $file, $out);


                echo $cur[$i], '=', $out[1], ',.... ';
            }
            $conn = mysql_connect($this->mysql_host, $this->mysql_user, $this->mysql_pass);
            $rs = mysql_select_db($this->mysql_db);



// i need a script to insert $ CUR  and $ out into my database.
pls help me


        }
    }

}
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 34340660
This question was specifically about obtaining the conversion rates, and that issue was resolved.  You should open a new question for your new question.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Suggested Courses

604 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