在做内容站时,经常会用到采集软件在互联网上大肆侵略别站的资源,一采集就是几千篇的文章,采集之后,发现内容中有些原站点的超级链接,要是一个个去改的话,很麻烦,所以写了个方法,测试成功。
简单说一下原理,这里重利用的是 PHP 的替换函数 preg_replace,在实际应用中,我们经常使用 preg_replace 去替换一些危险字符或去转换一些斜杠或回车等.
preg_replace($1,$2,$3) 有三个重要的参数,其中 $1 是要搜索的字符串,$2 是要替换成的字符串,$3 是要进行替换的字符串。
那么知道了 preg_replace 函数工作的原理,那么进行替换超链接就不难了,我们只需要将参数 $1 和 $2 转换成数组,进行批量替换,以下是方法,测试成功,共享给 phper,代码如下:
- <?php
- $str="<a href="xxx">超级链接</a>|<a href="xxx">这是个链接</a><br>";
- function removelink($str){
- $mode=array("#<a href="(.*)">#iUs","#</a>#iUs");
- $want=array("","");
- $con=preg_replace($mode,$want,$str);
- return $con;
- }
- echo removelink($str);
- ?>
或如下代码:
- <?php
- $content = file_get_contents('test.html');
- $url = 'http://www.phpfensi.com'; //要换成的新网址
- $preg = '/[s]href=("|')[S]*("|')/i';
- $replace = ' href="' . $url . '"';
- $content = preg_replace($preg, $replace, $content); //正则替换
- create_log('newhtml', $content); //生成新文件
- ?>
都是可以的.
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » PHP 批量删除网页内容中超级链接
波比源码 » PHP 批量删除网页内容中超级链接
levofloxacin cost purchase levofloxacin pill
brand avodart 0.5mg oral avodart 0.5mg zofran online order
order spironolactone generic valacyclovir pill buy fluconazole 200mg without prescription
ampicillin medication bactrim buy online purchase erythromycin for sale
order sildenafil pill order fildena 100mg sale methocarbamol drug
buy sildenafil 100mg without prescription purchase sildalis without prescription estradiol 2mg for sale
lamictal generic buy prazosin 1mg without prescription order tretinoin gel without prescription
cost tadalis order avana 200mg without prescription buy voltaren 50mg sale
isotretinoin 20mg cost azithromycin 500mg canada brand zithromax 250mg
purchase indomethacin pill order indomethacin 75mg pill trimox pill
order cialis online cheap new ed treatments buy viagra 50mg sale
anastrozole tablet Viagra 100mg england order sildenafil
tadalafil 20mg generique pas cher sildenafil 200mg comprimГ© viagra 100mg generique pas cher
order prednisone 20mg pills cialis online no prescription order sildenafil 100mg generic
accutane online order buy isotretinoin 10mg generic ivermectina
buy provigil for sale modafinil 200mg ca order diamox 250mg sale
order ramipril 5mg generic altace 5mg sale buy azelastine 10 ml without prescription
purchase fosamax generic buy ibuprofen 400mg generic famotidine pills
olmesartan 20mg usa calan 240mg us order diamox 250mg generic
purchase tacrolimus oral ursodiol cheap ursodiol 300mg
bupropion oral buy seroquel 50mg sale seroquel 100mg brand
buy zoloft 100mg generic cost sertraline 50mg order sildenafil online cheap
order tadalafil 40mg generic Buy cialis now buy viagra 50mg generic
buy cialis 20mg symmetrel uk amantadine ca
oral naltrexone 50mg purchase revia without prescription abilify 20mg usa
buy dapsone 100 mg online cheap perindopril over the counter perindopril 4mg tablet
cost medroxyprogesterone order biltricide generic cyproheptadine generic
fluvoxamine online buy glucotrol pills glucotrol 5mg canada
piracetam online buy order nootropil online order viagra 50mg sale
buy lasix 100mg plaquenil order online order plaquenil 400mg pills
order chloroquine baricitinib 4mg for sale baricitinib order
order itraconazole 100mg pill purchase sporanox tinidazole 500mg over the counter
amlodipine canada buy amlodipine online order tadalafil online cheap
sildenafil over the counter sildenafil 20mg lisinopril 10mg drug
purchase lopressor online cheap order metoprolol 100mg without prescription buy vardenafil 10mg for sale
buy a essay online get assignments done online real viagra
buy aristocort 4mg pills aristocort 4mg canada buy desloratadine online
order tadalafil 40mg buy tadalafil 20mg for sale viagra 50mg drug
cost orlistat 120mg diltiazem 180mg usa order generic zovirax 400mg
oral cialis 40mg order tadalafil 40mg pill cheap clopidogrel 75mg
allopurinol pill buy zetia 10mg pills zetia 10mg oral
cozaar 25mg tablet brand topiramate 200mg order topamax 200mg pill
buy colchicine without prescription online blackjack with real money casino gambling
ranitidine sale order mobic 15mg generic order celecoxib 200mg without prescription
zocor generic valacyclovir 500mg pills propecia 1mg uk
buy diflucan viagra 100mg cheap order generic viagra
oral keflex erythromycin 250mg usa erythromycin over the counter
tadalafil 20mg generic tadalafil 40mg for sale cheap viagra online
sildenafil order cialis coupon cvs order cialis 5mg
best online gambling tadalafil 10mg tablet buy tadalafil 5mg generic
buy generic trazodone purchase sildenafil pills aurogra pill
sildenafil 100mg pills for sale sildenafil 25mg lamictal sale
cost prednisone buy amoxil 500mg online cheap buy amoxicillin 1000mg
viagra 100mg price cost sildenafil cialis 10mg brand
hollywood casino low cost ed pills cialis 10mg ca
lasix online lasix 100mg cost hydroxychloroquine 200mg uk
fildena 50mg usa sildenafil generic rhinocort brand
order tretinoin cream generic avanafil online order avana 200mg pill
purchase tadalafil for sale tadacip online buy indocin 50mg pills
buy terbinafine cefixime 200mg ca trimox generic
clarithromycin 250mg uk purchase meclizine without prescription purchase antivert pills
oral naprosyn 250mg cefdinir 300 mg sale prevacid usa
order albuterol for sale order protonix 20mg online cipro us
order pioglitazone 30mg online sildenafil 150mg for sale buy viagra 100mg online cheap
roulette online real money sports gambling real casinos online no deposit
cheap nifedipine 10mg buy adalat pills fexofenadine 120mg canada
buy ramipril 10mg for sale etoricoxib tablet arcoxia sale
generic mesalamine 400mg cheap asacol 400mg irbesartan order
order generic acetazolamide buy acetazolamide 250 mg pill generic azathioprine 25mg
digoxin 250 mg brand oral telmisartan 80mg order molnunat sale
carvedilol usa buy coreg 25mg for sale elavil canada
purchase tricor pills sildenafil pills 50mg order sildenafil 100mg pill
Thank you great post. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
esomeprazole 40mg for sale furosemide over the counter purchase lasix without prescription
buy minocycline 50mg online cheap oral minocin 100mg hytrin 1mg canada
order metformin 1000mg online buy generic calan 240mg buy nolvadex 10mg generic
clomiphene pills buy prednisolone 40mg pills buy prednisolone generic
buy generic absorica generic isotretinoin 20mg ampicillin uk
order sildenafil pills purchase lyrica generic oral finasteride 5mg
ivermectin gel cost deltasone 5mg order deltasone 20mg generic
zofran 8mg brand amoxil 500mg oral bactrim 960mg ca
albuterol pill levoxyl us amoxiclav sale
prednisolone 20mg for sale buy prednisolone 20mg for sale brand lasix
cost vibra-tabs generic doxycycline order acyclovir sale
buy imuran 25mg generic order naprosyn 500mg without prescription buy naproxen 500mg without prescription