English 中文(简体)
尿液中的 gr取数据
原标题:grabing data from url
  • 时间:2010-03-20 18:02:07
  •  标签:
  • php

i have a task - i must grab some data from the URL. the link is http://cba.am. the data, i want to take, are in the some table, and i have the only one identifier, to reach my wanted data, it s the word "usd", which writes in that table(html)! i ve written the following script, and it works! but i never heard how more experienced programers do such things, so i want to hear your comments.


页: 1

<?php
    $str = file_get_contents("http://cba.am/");
    $key_usd = "USD";
    $sourse_usd_1 = explode($key_usd,$str);
    $usd1 = $sourse_usd_1[2];
    $sourse_usd_2=explode(">",$usd1);
    $usd2 = $sourse_usd_2[4];
    $sourse_usd_3=explode("<",$usd2);
    $usd = $sourse_usd_3[0];
?>

贫困的english:

最佳回答

只要这种做法对你有用(而且不会给你使用它带来麻烦),那就是一种罚款。 这一技术称为“治疗”。 但是,如果他们决定改变其网站结构,例如改变超文本标签或立场,则你的文字就会中断,你必须更新。 (如果数字没有意义,那么你就有了更好的机制,可以警告你)

更更好和更清洁的方法是(如果是中央银行)以明确的形式公布数据,例如作为网络服务、RSS馈赠或XML产出,供你查阅。

问题回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签