php替换掉,PHP str_是否用通配符替换擦掉的内容?

也许我的问题写得不好。我有一张桌子,我需要从一个网站上刮下来。我需要表中的信息,但必须清理前面提到的一些部分。我最终的解决方案是这个,而且很有效。它仍然有一些工作与手动更换,但那是因为愚蠢的“他们使用英寸”。;-)

解决方案:

\\ find the table in the sourcecode

foreach($techdata->find('table') as $table){

\\ filter out the rows

foreach($table->find('tr') as $row){

\\ take the innertext using simplehtmldom

$tech_specs = $row->innertext;

\\ strip some 'garbage'

$tech_specs = str_replace(" \t\t\t\t\t\t\t\t\t\t\t

","", $tech_specs);

\\ find the first word of the string so I can use it

$spec1 = explode('

', $tech_specs)[0];

\\ use the found string to strip down the rest of the table

$tech_specs = str_replace("

",":", $tech_specs);

\\ manual correction because of the " used

$tech_specs = str_replace("

",":", $tech_specs);

\\ manual correction because of the " used

$tech_specs = str_replace("

",":", $tech_specs);

\\ strip some 'garbage'

$tech_specs = str_replace("\t\t\t\t\t\t\t\t\t\t","\n", $tech_specs);

$tech_specs = str_replace("

","", $tech_specs);

$tech_specs = str_replace(" ","", $tech_specs);

\\ put the clean row in an array ready for usage

$specs[] = $tech_specs;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值