php168讨论区论坛 » PHP168帮助中心 » 数据采集指南 » 采集参数用到的正则语法讲解

PHP168专用空间1G 150元/年 送域名和数据库

广告位招租,联系QQ:121727818

1G双线双IP高速空间+200M数据库=158

1G双线空间+CN+邮局+SQL=99 免费代办备案

整站系统v5.0正式版下载 PHP168整站系统安装及使用教程 PHP168整站4.0风格精选区

P8-Server服务器套件(方便大家在自己的电脑上调试)

本页主题: 采集参数用到的正则语法讲解 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

龙城 该用户目前不在线

级别: 超级管理员
发帖: 10734
积分: 28704 点
铜板: 88 个
注册时间:2003-07-12
最后登录:2008-09-07

采集参数用到的正则语法讲解

所用的正则语法,目的就是实现通配符的

它的语法规则是

{变量名=NO符号}
{变量名=*}
{NO符号}
{*}

第一种与第三种一般用到标题的正则规则那里,
第二种与第四种一般用到内容的正则规则那里.

对于第一种而言,比如
{url=NO"}
代表的意思是,文章内容的网址是不能包括"双引号的.而凭什么就写"双引号,不写其它符号呢?这还得查看一下被采集的网站的列表页的源代码,看一下任意一篇的文章地址右边的是什么符号,如果是'单引号的话就输入'单引号,如果都不是的话.是空格的话.就输入空格.如果是>大于号的话.就输入>大于号.以此类推.遵循的原则就是靠近右边原则.

对于第二种,比如
{cotent=*}
*号代表的意思是,任意字符串.为什么内容页可以使用*号,而标题页不能使用呢?因为标题而是有多组标题的.而内容页不可能出现多组内容.
同样的道理.内容页是只有一个作者或一个来源地址的.所以就可以很方便的.只使用*号即可.而标题列表页是不能的.

{NO符号}{*}这两个所代表的意思,是不赋值给任何参数变量.因为他左边没有=等于号.使用这两个的目的是,为了实现通配符.比如在列表页的时候.一个链接地址如下
<a href='地址' title='描述'>标题</a>

像描述,我们是用不到的.但是你也要为它写一个通配符.因为每个标题的描述不一样的.所以就要写通配符.也就是说.凡是出现不需要的代码.但每个标题都不一样的.那就需要使用通配符.除了描述之外.有时也会有其它一些CSS样式等之类的.

而{*}一般用在文章内容里边.即是作者跟内容之间有一大段不需要的代码.无论相同或者不同.我们都不需要它.就用{*}代替


而变量一般有
title  文章标题
url    被采集的文章内容网址
content    文章内容
author      文章作者
copyfrom  文章来源
本帖最近评分记录:
  • 积分:+5(zxjxl918) 原创内容
  • 顶端 Posted: 2008-04-17 19:22 | [楼 主]
    邱比特之箭 该用户目前不在线
    近期活跃奖
    授权用户
    级别: 硕士
    发帖: 1766
    积分: 5750 点
    铜板: 51 个
    注册时间:2006-04-29
    最后登录:2008-09-04

    谢谢分享
    玉米低价转让http://www.php168cms.cn  www.p8cms.cn
    顶端 Posted: 2008-04-17 19:28 | 1 楼
    飞鸿踏雪 该用户目前不在线
    荣誉市民奖 灌水天才奖 五一雷锋奖 宣传贡献奖 优秀斑竹奖
    头衔:信念成就未来 信念成就未来
    授权用户
    级别: 总版主
    发帖: 7629
    积分: 12703 点
    铜板: 1179 个
    注册时间:2007-09-28
    最后登录:2008-09-06

    学习了。谢谢!

    飞蓬欲卷世时寒  鸿鹄凌云志比天
      踏破尘路闲入梦  雪霁方晴作笑谈
    顶端 Posted: 2008-04-17 19:30 | 2 楼
    销魂曲 该用户目前不在线
    优秀斑竹奖 荣誉市民奖 采集专业户
    头衔:SOULDO.CN SOULDO.CN
    授权用户
    级别: 斑竹
    发帖: 3203
    积分: 1024 点
    铜板: 50 个
    注册时间:2007-05-30
    最后登录:2008-09-07

    虽然早就明白,不过还是看一下标准说法,以后好回答。
    顶端 Posted: 2008-04-17 19:38 | 3 楼
    wbl 该用户目前不在线

    级别: 本科生
    发帖: 500
    积分: 2284 点
    铜板: 10 个
    注册时间:2008-04-09
    最后登录:2008-09-06

    我的通通收集,准备出书呵呵
    *****************************************
    *      签名档欠费,点击续费!        *
    *****************************************
    顶端 Posted: 2008-04-17 19:44 | 4 楼
    meiok 该用户目前不在线

    授权用户
    级别: 大专生
    发帖: 653
    积分: 1352 点
    铜板: 77 个
    注册时间:2007-06-04
    最后登录:2008-09-06

    老大最近都忙这些吗,2008的升级等得。。。。。
    顶端 Posted: 2008-04-17 20:02 | 5 楼
    zxjxl918 该用户目前在线
    优秀斑竹奖 荣誉市民奖 终身荣誉奖
    头衔:超级版猪 超级版猪

    1星级VIP用户
    授权用户
    级别: 斑竹
    发帖: 6842
    积分: 3236 点
    铜板: 765 个
    注册时间:2005-03-31
    最后登录:2008-09-07

    学习一下
    顶端 Posted: 2008-04-18 15:54 | 6 楼
    crespo1980 该用户目前不在线



    级别: 幼儿园
    发帖: 204
    积分: 115 点
    铜板: 0 个
    注册时间:2007-05-30
    最后登录:2008-09-06

    学习当中,受益匪浅
    顶端 Posted: 2008-05-05 21:21 | 7 楼
    dataodahan 该用户目前不在线



    级别: 托儿所
    发帖: 97
    积分: 0 点
    铜板: 2 个
    注册时间:2008-05-10
    最后登录:2008-09-02

    谢谢你啊!~
    *****************************************
    *      签名档欠费,点击续费!        *
    *****************************************
    顶端 Posted: 2008-05-12 17:10 | 8 楼
    fcsgame01 该用户目前不在线

    级别: 托儿所
    发帖: 4
    积分: 3 点
    铜板: 0 个
    注册时间:2008-05-16
    最后登录:2008-05-28

    Clinton looks past assassination comments

    HORMIGUEROS, Puerto Rico -- Hillary Clinton's campaign prepared for its next big test as it tried on Sunday to move away from her controversial remarks about the assassination of Robert Kennedy 40 years ago.


    US Democratic presidential hopeful, Sen. Hillary Rodham Clinton, hoists a 'Presidente' beer at Sabor Latino Restaurant & Bar in San Juan, Puerto Rico, May 25, 2008. [Agencies]
    The New York senator campaignedtibia gold
    in Puerto Rico ahead of the island's Democratic presidential primary next Sunday, but before that she faces a major showdown -- possibly the final one -- when party officials meet to decide what to do with delegates from Florida and Michigan.

    A decision on Saturday in her favor by the Democratic rules committee is key to her uphill fight with Barack Obama to win the tibia money
    Democratic nomination at the party convention this summer and face Republican John McCain in the November election.

    The two states, who were stripped of their convention delegates for violating party primary rules, are believed to be formulating plans to allow at least some of the delegates to be counted.

    Campaign chairman Terry McAuliffe was asked if Clinton would accept a decision that she did not particularly like.

    "I am not saying that today," he said on "Fox News Sunday." "I'm saying let them make their decision and then we will determine."

    Campaigning for a second day in Puerto Rico, where she is favored in Sunday's voting, Clinton accepted an invitation from a local television station to debate Obama on issues facing the island. "Anytime, anywhere," she said at a stop in Penuelas.

    Puerto Ricans can help pick the Democratic nominee but the territory does not have the right to vote for president in November.

    "If I had listened to those who had been talking the last several months, we would not been having this campaign in Puerto wow gold
    Rico today," she told a congregation of several hundred people in an evangelical church in Hormigueros.

    Even as she tried to get the political discussion back to topics like the economy, her comments citing Robert Kennedy's assassination after winning the June 1968 California presidential primary were still the focus of political talk.

    Context of Remarks

    Writing in the New York Daily News, Clinton again explained she had mentioned the assassination in the historical context of a campaign world of warcraft gold
    that continued well into June. The former first lady said her remarks were taken out of context.

    "I was deeply dismayed and disturbed that my comment would be construed in a way that flies in the face of everything eve isk</a>
    I stand for -- and everything I am fighting for in this election," she wrote.

    Others saw the mere mention of assassination as a reminder of the role such killings have played in US politics and that Obama, who would be the first black US president, has had Secret Service protection for more than year.
    *****************************************
    *      签名档欠费,点击续费!        *
    *****************************************
    顶端 Posted: 2008-05-28 06:50 | 9 楼
    棒棒狗 该用户目前不在线

    级别: 禁止发言
    发帖: 9
    积分: 5 点
    铜板: 0 个
    注册时间:2008-04-28
    最后登录:2008-06-15

    用户被禁言,该主题自动屏蔽!
    顶端 Posted: 2008-05-28 20:48 | 10 楼
    lxkjpf 该用户目前不在线

    级别: 幼儿园
    发帖: 56
    积分: 69 点
    铜板: 0 个
    注册时间:2008-02-23
    最后登录:2008-09-01

       
    *****************************************
    *      签名档欠费,点击续费!        *
    *****************************************
    顶端 Posted: 2008-05-30 00:39 | 11 楼
    yxt 该用户目前不在线



    级别: 幼儿园
    发帖: 28
    积分: 51 点
    铜板: 0 个
    注册时间:2008-05-26
    最后登录:2008-06-23

    学习中,我想有一个自己的网站。
    顶端 Posted: 2008-06-01 12:33 | 12 楼
    mai123 该用户目前不在线

    级别: 托儿所
    发帖: 1178
    积分: 2 点
    铜板: 11 个
    注册时间:2008-04-07
    最后登录:2008-09-06

    行啊!!老大出的都是精品!
    祝P8里的朋友天天开心~~~

    顶端 Posted: 2008-07-08 13:02 | 13 楼
    php168讨论区论坛 » 数据采集指南
    以铜板换广告位一 以铜板换广告位二 以铜板换广告位三 以铜板换广告位四
    以铜板换广告位五 以铜板换广告位六 以铜板换广告位七 示范站-泡泡娱乐网

    Total 0.142942(s) query 4, Time now is:09-07 03:13, Gzip disabled
    Powered by PHPWind v5.3 Certificate Code © 2003-07 PHPWind.com Corporation 京ICP备05047353号