Php 从Go Daddy';价目表
我想为流行域名的一般TLD刮更新定价Php 从Go Daddy';价目表,php,regex,web-scraping,Php,Regex,Web Scraping,我想为流行域名的一般TLD刮更新定价 我正在寻找源代码,但没有看到价格数字。。。。在哪里可以找到这些变量 价格在页面加载后动态生成。。。这是默认表的价格链接 它返回一个json文件,可以使用 要查看与页面交互时动态变化的内容,请在chrome中启动developer tools,然后从顶部启动Network选项卡,从底部启动XHR选项卡 在该选项卡中,您将看到网站和服务器之间的所有动态通信 编辑: 下面是一个工作示例: // includes Simple HTML DOM Parser re
我正在寻找源代码,但没有看到价格数字。。。。在哪里可以找到这些变量 价格在页面加载后动态生成。。。这是默认表的价格链接 它返回一个json文件,可以使用 要查看与页面交互时动态变化的内容,请在chrome中启动
developer tools
,然后从顶部启动Network
选项卡,从底部启动XHR
选项卡
在该选项卡中,您将看到网站和服务器之间的所有动态通信
编辑:
下面是一个工作示例:
// includes Simple HTML DOM Parser
require_once "php/lib/simplehtmldom_1_5/simple_html_dom.php";
$url = "https://www.godaddy.com/domains/controls/jsoncontent/generalpricing.aspx?tab=general&widthreduction=160&hidelinks=true&TargetDivId=tabgj_new®t=new&_=1380620289373";
// Download json file and converts it into a PHP variable
$jsonData = json_decode(file_get_contents($url));
// get html data from the json object
$htmlData = $jsonData->Html;
/*
* Parse the HTML DOM using Simple HTML DOM Parser
*/
//Create a DOM object
$html = new simple_html_dom();
// Load HTML from a string
$html->load($htmlData);
// Print results
foreach($html->find("table tr") as $index => $row) {
switch ($index) {
case '0': // Print table header
foreach($row->find("th") as $col) {
echo $col->plaintext;
echo " | ";
}
echo "<br/>---<br/>";
break;
default: // Print all rows
foreach($row->find("td") as $col) {
echo $col->plaintext;
echo " | ";
}
echo "<br/>---<br/>";
break;
}
}
OUTPUT:
-------
Per year pricing | 1 year | 2 years | 3 years | 5 years | 10 years |
---
.COM | $12.99* $14.99* | $13.99* $14.99* | $14.33* $14.99* | $14.59* $14.99* | $14.79* $14.99* |
---
.CO | $12.99 $29.99 | $21.49 $29.99 | $24.33 $29.99 | $26.59 $29.99 | -- |
---
.INFO | $2.99* $14.99* | $8.99* $14.99* | $10.99* $14.99* | $12.59* $14.99* | $13.79* $14.99* |
---
.ORG | $9.99* $17.99* | $13.99* $17.99* | $15.33* $17.99* | $16.39* $17.99* | $17.19* $17.99* |
---
.NET | $9.99* $16.99* | $13.49* $16.99* | $14.66* $16.99* | $15.59* $16.99* | $16.29* $16.99* |
---
.ME | $9.99 $19.99 | $14.99 $19.99 | $16.66 $19.99 | $17.99 $19.99 | $18.99 $19.99 |
---
.MOBI | $9.99* $17.99* | $13.99* $17.99* | $15.33* $17.99* | $16.39* $17.99* | $17.19* $17.99* |
---
.US | $3.99 $19.99 | $11.99 $19.99 | $14.66 $19.99 | $16.79 $19.99 | $18.39 $19.99 |
---
.BIZ | $6.99* $16.99* | $11.99* $16.99* | $13.66* $16.99* | $14.99* $16.99* | $15.99* $16.99* |
---
.CA | $12.99 | $12.99 | $12.99 | $12.99 | $12.99 |
---
.CC | $19.99 | $19.99 | $19.99 | $19.99 | $19.99 |
---
.LA | $39.99 | $39.99 | $39.99 | $39.99 | $39.99 |
---
.TV | $39.99 | $39.99 | $39.99 | $39.99 | $39.99 |
---
.WS | $15.99 | $15.99 | $15.99 | $15.99 | $15.99 |
---
.ASIA | $19.99* | $19.99* | $19.99* | $19.99* | $19.99* |
---
.XXX | $99.99* | $99.99* | $99.99* | $99.99* | $99.99* |
---
//包括简单的HTML DOM解析器
require_once“php/lib/simplehtmldom_1_5/simple_html_dom.php”;
$url=”https://www.godaddy.com/domains/controls/jsoncontent/generalpricing.aspx?tab=general&widthreduction=160&hidelinks=true&TargetDivId=tabgj_new®t=new&_=1380620289373";
//下载json文件并将其转换为PHP变量
$jsonData=json_解码(文件获取内容($url));
//从json对象获取html数据
$htmlData=$jsonData->Html;
/*
*使用简单的HTMLDOM解析器解析HTMLDOM
*/
//创建DOM对象
$html=新的简单html\U dom();
//从字符串加载HTML
$html->load($htmlData);
//打印结果
foreach($html->find(“table tr”)作为$index=>$row){
交换机($索引){
案例“0”://打印表头
foreach($row->find(“th”)作为$col){
echo$col->纯文本;
回声“|”;
}
回声“
--
”;
打破
默认值://打印所有行
foreach($row->find(“td”)作为$col){
echo$col->纯文本;
回声“|”;
}
回声“
--
”;
打破
}
}
输出:
-------
每年定价| 1年| 2年| 3年| 5年| 10年|
---
.COM |$12.99*$14.99*|$13.99*$14.99*|$14.33*$14.99*|$14.59*|$14.99*|$14.79*|
---
.CO |$12.99$29.99 |$21.49$29.99 |$24.33$29.99 |$26.59$29.99 |--
---
.INFO$2.99*$14.99*$8.99*$14.99*$10.99*$14.99*$12.59*$14.99*$13.79*$14.99*$
---
.ORG |$9.99*$17.99*$13.99*$17.99*$15.33*$17.99*$16.39*$17.99*$17.19*$17.99*$
---
.NET |$9.99*$16.99*|$13.49*$16.99*|$14.66*$16.99*|$15.59*|$16.99*|$16.29*|
---
.ME |$9.99$19.99 |$14.99$19.99 |$16.66$19.99 |$17.99$19.99 |$18.99$19.99 |
---
.MOBI |$9.99*$17.99*|$13.99*$17.99*|$15.33*$17.99*|$16.39*$17.99*|$17.19*|
---
.US | 3.99美元19.99美元11.99美元19.99美元14.66美元19.99美元16.79美元19.99美元18.39美元19.99美元
---
.BIZ$6.99*$16.99*$11.99*$16.99*$13.66*$16.99*$14.99*$16.99*$15.99*$16.99*$
---
.CA |$12.99 |$12.99 |$12.99 |$12.99 |$12.99 |
---
.CC |$19.99 |$19.99 |$19.99 |$19.99 |$19.99 |
---
.LA |$39.99 |$39.99 |$39.99 |$39.99 |$39.99 |
---
.TV |$39.99 |$39.99 |$39.99 |$39.99 |$39.99 |
---
.WS |$15.99 |$15.99 |$15.99 |$15.99 |$15.99 |
---
.亚洲|$19.99*|$19.99*|$19.99*|$19.99*|$19.99*|
---
.XXX |$99.99*|$99.99*|$99.99*|$99.99*|$99.99*|
---
如何解析JSON?我会拉html部分,然后运行html解析器从表中获取续费价格吗?哦,我没有注意到它包含html代码。。。但这就是想法,你得到html代码,然后你用一些dom解析器解析它,比如。。。稍后我将发布一个示例…@user1512405,示例已添加。。。有关更多详细信息,请参阅