锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
You've probably already heard of RSS, the XML-based format which allows
Web sites to publish and syndicate the latest content on their site to
all interested parties. RSS is a boon to the lazy Webmaster, because
(s)he no longer has to manually update his or her Web site with new
content.
Instead, all a Webmaster has to do is plug in an RSS client,
point it to the appropriate Web sites, and sit back and let the site
"update itself" with news, weather forecasts, stock market data, and
software alerts. You've already seen, in previous articles,
how you can use the ASP.NET platform to manually parse an RSS feed and
extract information from it by searching for the appropriate elements.
But I'm a UNIX guy, and I have something that's even better than
ASP.NET. It's called Perl.
Installing XML::RSS
Written entirely in Perl, XML::RSS isn't included with Perl by default, and you must install it from CPAN.
Detailed installation instructions are provided in the download
archive, but by far the simplest way to install it is to use the CPAN
shell, as follows:
shell> perl -MCPAN -e shell If you use the CPAN shell, dependencies will be automatically
downloaded for you (unless you told the shell not to download dependent
modules). If you manually download and install the module, you may need
to download and install the XML::Parser module before XML::RSS can be
installed. The examples in this tutorial also need the LWP::Simple
package, so you should download and install that one too if you don't
already have it.
Basic usage
Listing A
"; }
# print footers
print "
Place the script in your Web server's cgi-bin/ directory/. Remember to
make it executable, and then browse to it using your Web browser. After
a short wait for the RSS file to download, you should see something
like Figure A.
The various elements of the RSS feed are converted into Perl structures, and a foreach()
loop is used to iterate over the array of items. Each item contains
properties representing the item name, URL and description; these
properties are used to dynamically build a readable list of news items.
Each time Slashdot updates its RSS feed, the list of items displayed by
the script above will change automatically, with no manual intervention
required.
The script in Listing A will work with other RSS feeds as well鈥攕imply alter the URL passed to the LWP's get() method, and watch as the list of items displayed by the script changes.
Tip: Notice that the RSS channel name (and description) can be obtained with the object's channel() method, which accepts any one of three arguments (title, description or link) and returns the corresponding channel value.
Adding multiple sources and optimising performance
Listing B
"; }
# print footers
print "
Figure B shows you what it looks like.
You'll notice, if you're sharp-eyed, that Listing B uses the parsefile()
method to read a local version of the RSS file, instead of using LWP to
retrieve it from the remote site. This revision results in improved
performance, because it does away with the need to generate an internal
request for the RSS data source every time the script is executed.
Fetching the RSS file on each script run not only causes things to go
slow (because of the time taken to fetch the RSS file), but it's also
inefficient; it's unlikely that the source RSS file will change on a
minute-by-minute basis, and by fetching the same data over and over
again, you're simply wasting bandwidth. A better solution is to
retrieve the RSS data source once, save it to a local file, and use
that local file to generate your page.
Depending on how often the source file gets updated, you can
write a simple shell script to download a fresh copy of the file on a
regular basis.
Here's an example of such a script:
#!/bin/bash
This script uses the wget utility (included with most Linux distributions) to download and save the RSS file to disk. Add this to your system crontab, and set it to run on an hourly or daily basis.
If you find performance unacceptably low even after using local
copies of RSS files, you can take things a step further, by generating
a static HTML snapshot from the script above, and sending that to
clients instead. To do this, comment out the line printing the
"Content-Type" header in the script above and then run the script from
the console, redirecting the output to an HTML file. Here's how:
$ ./rss.cgi > static.html
Now, simply serve this HTML file to your users. Since the file
is a static file and not a script, no server-side processing takes
place before the server transmits it to the client. You can run the
command-line above from your crontab
to regenerate the HTML file on a regular basis. Performance with a
static file should be noticeably better than with a Perl script.
Looks easy? What are you waiting for鈥攇et out there and start hooking your site up to your favorite RSS news feeds.
鏈榪戞悳闆?b style="color: black; background-color: rgb(160, 255, 255);">RSS瑙f瀽宸ュ叿涓壘鍒頒簡MagPieRSS 鍜屽熀浜庡叾璁捐鐨?a >Lilina錛汱ilina鐨勪富瑕佸姛鑳斤細 1 鍩轟簬WEB鐣岄潰鐨?b style="color: black; background-color: rgb(160, 255, 255);">RSS綆$悊錛氭坊鍔狅紝鍒犻櫎錛孫PML瀵煎嚭錛?b style="color: black; background-color: rgb(160, 255, 255);">RSS鍚庡彴緙撳瓨鏈哄埗錛堥伩鍏嶅鏁版嵁婧愭湇鍔″櫒浜х敓榪囧ぇ鍘嬪姏錛夛紝ScriptLet: 綾諱技浜嶥el.icio.us it鐨勬敹钘忓す鍗蟲椂璁㈤槄JS鑴氭湰錛?/p>
2 鍓嶅彴鍙戝竷錛氬皢鑷繁鐨勯欏墊敼鎴愪簡鐢↙ilina鍙戝竷鎴戝父鐪嬬殑鍑犱釜鏈嬪弸鐨勭綉蹇楋紝涔熺渷鍘諱簡寰堝鏇存柊鑷繁緗戦〉鐨勫伐浣滐紝闇瑕?strong>php 4.3 + mbstring iconv 璁板緱騫村垵Wen Xin鍦–NBlog鐨勭爺璁ㄤ細涓婁粙緇嶄簡涓漢闂ㄦ埛鐨勬蹇碉紝闅忕潃RSS鍦–MS鎶鏈腑鐨勬垚鐔燂紝瓚婃潵瓚婂鐨勬湇鍔″彲浠ヨ涓漢鐢ㄦ埛鏍規嵁鑷繁闇姹傛瀯寤洪棬鎴鳳紝涔熺畻鏄鍚堜簡浜掕仈緗戠殑闈炰腑蹇冨寲瓚嬪娍鍚э紝姣斿鍒╃敤Add to My Yahoo!鍔熻兘錛岀敤鎴峰彲浠ヨ交鏉劇殑瀹炵幇鑷繁浠庢洿澶氭暟鎹簮榪涜鏂伴椈璁㈤槄銆傛兂璞′竴涓嬫妸浣犺嚜宸辯殑del.icio.us涔︾鏀惰棌 / flickr鍥劇墖鏀惰棌 / Yahoo!鏂伴椈閮介氳繃榪欐牱涓涓?b style="color: black; background-color: rgb(160, 255, 255);">RSS鑱氬悎鍣ㄨ仛鍚?鍙戝竷璧鋒潵銆傚叾浼犳挱鏁堢巼灝嗘湁澶氬揩銆?/p>
濂芥瘮杞歡寮鍙戦氳繃涓棿騫沖彴/铏氭嫙鏈哄疄鐜幫細涓嬈″啓鎴愶紝闅忓榪愯錛圵rite once, run anywhere錛夛紝閫氳繃RSS/XML榪欎釜涓棿灞傦紝淇℃伅鍙戝竷涔熷疄鐜頒簡錛氫竴嬈″啓鎴愶紝闅忓鍙戝竷錛圵rite once, publish anywhere...錛?/p>
瀹夎Lilina闇瑕丳HP 4.3 浠ヤ笂錛屽茍甯︽湁iconv mbstring絳夊嚱鏁扮殑鏀寔錛岃紜涓涓?a --with-iconv' 鍙﹀灝辨槸涓涓渶瑕佽兘閫氳繃鏈嶅姟鍣ㄧ鍚戝閮ㄦ湇鍔″櫒鍙戦丷PC璇鋒眰錛岃繖鐐?1.NET涓嶆敮鎸併傛劅瑙?a >PowWeb鐨勬湇鍔?/a>寰堜笉閿欙紝寰堝緙虹渷鐨勫寘閮藉畨瑁呭ソ浜嗭細 iconv Directive Local Value Master Value mbstring 灝嗗畨瑁呭寘瑙e寘錛堜笅杞芥枃浠舵墿灞曞悕鏄?gz 鍏跺疄鏄?tgz錛岄渶瑕侀噸鍛藉悕涓涓嬶級錛氫笂浼犲埌鏈嶅姟鍣ㄧ浉搴旂洰褰曚笅錛屾敞鎰忥細鐩稿簲cache鐩綍鍜屽綋鍓嶇洰褰曠殑鍙啓鍏ュ睘鎬ц緗紝鐒跺悗閰嶇疆涓涓媍onf.php涓殑鍙傛暟鍗沖彲寮濮嬩嬌鐢ㄣ?/p>
浣曚笢緇欐垜鐨勫緩璁細 涓浜涙敼榪涜鍒掞細 " 瀹炵幇錛?br>
2 鍒嗙粍鍔熻兘錛氬皢RSS榪涜緇勮緭鍑猴紱 淇敼榛樿鏄劇ず瀹炵幇錛歀ilina緙虹渷鏄劇ず鏈榪?澶╁彂琛ㄧ殑鏂囩珷錛屽鏋滈渶瑕佹敼鎴愬叾浠栨椂闂村懆鏈熷彲浠ユ壘鍒幫細 榪涜鏀瑰姩銆?/p>
RSS鏄竴涓兘灝嗚嚜宸辯殑鎵鏈夎祫婧愶細WIKI / BLOG / 閭歡鑱氬悎璧鋒潵鐨勮交閲忕駭鍗忚錛屼互鍚庢棤璁轟綘鍦ㄤ綍澶勪功鍐欙紝鍙鏈?b style="color: black; background-color: rgb(160, 255, 255);">RSS鎺ュ彛灝遍兘鍙互閫氳繃涓瀹氭柟寮忚繘琛屽啀嬈$殑姹囪仛鍜屽彂甯冭搗鏉ワ紝浠庤屽ぇ澶ф彁楂樹簡涓漢鐭ヨ瘑綆$悊鍜屽彂甯?浼犳挱鏁堢巼銆?/p>
浠ュ墠瀵?b style="color: black; background-color: rgb(160, 255, 255);">RSS鐞嗚В闈炲父嫻咃細涓嶅氨鏄竴涓狣TD鍢涳紝鐪熶簡瑙h搗瑙f瀽鍣ㄦ潵錛屾墠鐭ラ亾namespace鐨勯噸瑕佹э紝涓涓ソ鐨勫崗璁篃搴旇鏄繖鏍風殑錛氬茍闈炴病鏈変粈涔堝彲鍔犵殑錛屼絾鑲畾鏄病鏈変粈涔堝彲鈥滃噺鈥濈殑浜嗭紝鑰岀湡鐨勮鍋氬埌榪欎釜鍏跺疄寰堥毦寰堥毦鈥︹︺?/p>
鎴戜細鍐嶅皾璇曚竴涓婮AVA鐨勭浉鍏寵В鏋愬櫒錛屽皢鍏舵墿灞曞埌WebLucene欏圭洰涓紝鏇村Java鐩稿叧Open Source RSS瑙f瀽鍣ㄨ祫婧?/a>銆?/p>
鍙﹀鎵懼埌鐨?涓嬌鐢?b style="color: black; background-color: rgb(255, 255, 102);">Perl榪涜RSS瑙f瀽鐨勫寘錛?br>
浣跨敤XML::RSS::Parser::Lite鍜?a >XML::RSS::Parser XML::RSS::Parser::Lite鐨勪唬鐮佹牱渚嬪涓嬶細 #!/usr/bin/perl -w use strict; # print blog header # convert item to <li> 瀹夎錛?br>
闇瑕丼OAP-Lite 浼樼偣錛?br>
鏂規硶綆鍗曪紝鏀寔榪滅▼鎶撳彇錛?/p>
緙虹偣錛?br>
鍙敮鎸乼itle, url, description榪?涓瓧孌碉紝涓嶆敮鎸佹椂闂村瓧孌碉紝 璁″垝鐢ㄤ簬綆鍗曠殑鎶撳彇RSS鍚屾鏈嶅姟璁捐錛氭瘡涓漢閮藉彲浠ュ嚭鐗堣嚜宸辮闃呯殑RSS銆?/p>
use strict; # output some values 浼樼偣錛?br>
鑳藉鐩存帴灝嗘暟鎹寜瀛楁杈撳嚭錛屾彁渚涙洿搴曞眰鐨勭晫闈紱 緙虹偣錛?br>
涓嶈兘鐩存帴瑙f瀽榪滅▼RSS錛岄渶瑕佷笅杞藉悗鍐嶈В鏋愶紱 2004-12-14: Planet鐨勫畨瑁咃細瑙e寘鍚庯紝鐩存帴鍦ㄧ洰褰曚笅榪愯錛歱ython planet.py examples/config.ini 灝卞彲浠ュ湪output鐩綍涓湅鍒扮己鐪佹牱渚婩EED涓殑杈撳嚭浜唅ndex.html錛屽彟澶栬繕鏈塷pml.xml鍜?b style="color: black; background-color: rgb(160, 255, 255);">rss.xml絳夎緭鍑猴紙榪欑偣姣旇緝濂斤級 鎴戠敤鍑犱釜RSS璇曚簡涓涓嬶紝UTF-8鐨勬病鏈夐棶棰橈紝浣嗘槸GBK鐨勫叏閮ㄩ兘涔辯爜浜嗭紝planetlib.py涓拰XML瀛楃闆嗗鐞嗙殑鍙湁浠ヤ笅浠g爜錛氱湅鏉ユ墍鏈夌殑闈濽TF-8閮借褰撲綔iso8859_1澶勭悊浜嗭細 榪戞湡瀛︿範涓涓婸ython鐨剈nicode澶勭悊錛屾劅瑙夋槸涓涓緢綆媧佺殑璇█錛屾湁姣旇緝濂界殑try ... catch 鏈哄埗鍜宭ogging 鍏充簬MagPieRSS鎬ц兘闂鐨勭枒铏戯細 鍙互鐪嬪埌錛歀ilina鐨勭紦瀛樻満鍒舵槸姣忔璇鋒眰鐨勬椂鍊欓亶鍘嗙紦瀛樼洰褰曚笅鐨?b style="color: black; background-color: rgb(160, 255, 255);">RSS鏂囦歡錛屽鏋滅紦瀛樻枃浠惰繃鏈燂紝榪樿鍔ㄦ佸悜RSS鏁版嵁婧愯繘琛岃姹傘傚洜姝や笉鑳芥敮鎸佸悗鍙板お澶氱殑RSS璁㈤槄鍜屽墠绔ぇ閲忕殑騫跺彂璁塊棶錛堜細閫犳垚寰堝鐨処/O鎿嶄綔錛夈?/p>
Planet鏄竴涓悗鍙拌剼鏈紝閫氳繃鑴氭湰灝嗚闃呯殑RSS瀹氭湡姹囪仛鎴愪竴涓枃浠惰緭鍑烘垚闈欐佹枃浠躲?/p>
鍏跺疄鍙鍦∕agPieRSS鍓嶇澧炲姞涓涓獁get鑴氭湰瀹氭湡灝唅ndex.php鐨勬暟鎹緭鍑烘垚index.html錛岀劧鍚庤姹傛瘡嬈¤闂厛璁塊棶index.html緙撳瓨錛岃繖鏍蜂笉灝卞拰Planet鐨勬瘡灝忔椂鐢熸垚index.html闈欐佺紦瀛樹竴鏍蜂簡鍚椼?/p>
鎵浠ュ湪涓嶅厑璁歌嚜宸遍厤緗湇鍔″櫒鑴氭湰鐨勮櫄鎷熶富鏈烘潵璇碢lanet鏍規湰鏄棤娉曡繍琛岀殑銆?/p>
鏇村鍏充簬PHP涓鐞咷BK鐨刋ML瑙f瀽闂璇峰弬鑰冿細 2004-12-19 Posted by chedong at December 11, 2004 12:34 AM
Edit
TrackBack URL for this entry: Listed below are links to weblogs that reference Lilina錛?b style="color: black; background-color: rgb(160, 255, 255);">RSS鑱氬悎鍣ㄦ瀯寤轟釜浜洪棬鎴?Write once, publish anywhere):
祿 MagPieRSS涓璘TF-8鍜孏BK鐨?b style="color: black; background-color: rgb(160, 255, 255);">RSS瑙f瀽鍒嗘瀽錛堥檮錛歱hp涓殑闈㈠悜瀛楃緙栫▼璇﹁В錛?/a> from 杞︿笢BLOG Tracked on December 19, 2004 12:37 AM
祿 鐢?lilina 鍜?blogline 鏉ョ湅 blog from Philharmania's Weblog Tracked on December 26, 2004 01:57 PM
祿 CNBlog浣滆呯兢RSS寰侀泦涓?/a> from CNBlog: Blog on Blog Tracked on December 26, 2004 07:42 PM Tracked on January 14, 2005 06:14 PM
祿 MT鐨勬ā鏉夸慨鏀瑰拰鐣岄潰鐨偆璁劇疆 from 杞︿笢BLOG Tracked on January 17, 2005 01:25 PM 璇烽棶濡傛灉鏇存敼榛樿鏄劇ず7澶╃殑鏂伴椈錛岃阿璋€?/p>
Posted by: honren at December 12, 2004 10:20 PM 鎴戜嬌鐢╨ilina宸茬粡涓孌墊椂闂翠簡銆?br>
http://news.yanfeng.org Posted by: mulberry at December 13, 2004 09:24 AM 鑰佽濺鍚屽織錛屾病瑙夊緱浣犱嬌鐢╨ilina浠ユ潵錛屼富欏電殑璁塊棶閫熷害鍏鋒參鍚楋紵鏀懼純鍚э紝鑷沖皯娌″繀瑕佸綋浣滈欏碉紝lilina榪樺湪鎶鏈繕涓嶆垚鐔焋~ Posted by: kalen at December 16, 2004 10:33 AM 鍙互鑰冭檻涓涓嬬敤drupal Posted by: shunz at December 28, 2004 06:46 PM 鍙互璇曡瘯鎴戝仛鐨勶細http://blog.terac.com 姣?灝忔椂鎶撳彇blog,鐒跺悗姣忎釜閫?鏉℃渶鏂扮殑錛屾帓搴忥紝鑱氬悎錛岀敓鎴愰潤鎬亁ml錛岀敤xsl鏍煎紡鍖栨樉紺恒傘傘?/p>
Posted by: andy at January 6, 2005 12:53 PM 杞︿笢鍚屽織錛岃繖鏍峰仛涓嶅ソ錛歅 The Rich Site Summary (RSS) format, previously known as the RDF Site
Summary, has quietly become the dominant format for distributing news
headlines on the Web. In this Mother of Perl tutorial, we will write a short Perl script
(less than 100 lines) that retrieves an XML RSS file from the Web or
local file system and converts it to HTML. Using a Server Side Include
(SSI) or similar method, you can easily add news headlines from any
number of sources to your Web site. Where did RSS come from you ask? Netscape invented the RSS format for "channels" on Netscape Netcenter (http://my.netscape.com). It was released to the public in March of 1999. The first non-Netscape Web site to incorporate the new format was Scripting News, a popular technology news site run by Dave Winer, president of Userland Software
(think Frontier). Interestingly enough, Scripting News had been using
its own XML format, scriptingNews, since December of 1997.
In May of 1999, Dave Winer released a new version of the
scriptingNews XML format, which added new content-rich elements.
Netscape followed suit by adopting most of the new scriptingNews
elements into RSS 0.91, which was released in July of 1999.
Userland Software also rolled out their own flavor of my.netscape.com. If you haven't already guessed, it's available at http://my.userland.com.
As far as I know, RSS is the most widely used XML format on the
Web today. RSS headlines are available for many popular news sites like
Slashdot,
Forbes, and CNET News.com, and the list is growing daily.
In a time when "stickiness" is a good, displaying news headlines
on your Web site can really help give it the extra "umph" that will
encourage users to return. After all, users can only read your
president's bio but so many times.
For rss2html.pl to work on your system, you should have a recent
version of Perl installed, 5.003 or better. 5.005 is recommended. You
will also need the XML::Parser and XML::RSS modules installed. To install the modules on a *nix system, type: If you're using a win32 machine (Win95/98/NT), you have a recent
installation of Activestate Perl. If you don't have a recent version,
visit http://www.activestate.com. To install XML::Parser on a win32 machine type: To install XML::RSS on a win32 machine (you must have a C compiler and nmake):
Next, we'll examine the RSS format in more detail.
December 22, 2004
URL: http://www.builderau.com.au/architect/webservices/0,39024590,39171461,00.htm
Take advantage of the XML::RSS CPAN package, which is specifically designed to read and parse RSS feeds.
RSS parsing in Perl is usually handled by the XML::RSS CPAN
package. Unlike ASP.NET, which comes with a generic XML parser and
expects you to manually write RSS-parsing code, the XML::RSS package is
specifically designed to read and parse RSS feeds. When you give
XML::RSS an RSS feed, it converts the various <item>s in the feed
into array elements, and exposes numerous methods and properties to
access the data in the feed. XML::RSS currently supports versions 0.9,
0.91, and 1.0 of RSS.
cpan> install XML::RSS
For our example, we'll assume that you're interested in displaying
the latest geek news from Slashdot on your site. The URL for Slashdot's
RSS feed is located here. The script in Listing A retrieves this feed, parses it, and turns it into a human-readable HTML page using XML::RSS:
#!/usr/bin/perl
# import packages
use XML::RSS;
use LWP::Simple;
# initialize object
$rss = new XML::RSS();
# get RSS data
$raw = get('http://www.slashdot.org/index.rss');
# parse RSS feed
$rss->parse($raw);
# print HTML header and page
print "Content-Type: text/html\n\n";
print "
print "";
print "
";" . $rss->channel('title') .
" ";
# print titles and URLs of news items
foreach my $item (@{$rss->{'items'}})
{
$title = $item->{'title'};
$url = $item->{'link'};
print "$title
print "";
Slashdot RSS feed
Here are some RSS feeds to get you started
So that takes care of adding a feed to your Web site. But hey, why limit yourself to one when you can have many? Listing B, a revision of the Listing A,
sets up an array containing the names of many different RSS feeds, and
iterates over the array to produce a page containing multiple channels
of information.
#!/usr/bin/perl
# import packages
use XML::RSS;
use LWP::Simple;
# initialize object
$rss = new XML::RSS();
# get RSS data
$raw = get('http://www.slashdot.org/index.rss');
# parse RSS feed
$rss->parse($raw);
# print HTML header and page
print "Content-Type: text/html\n\n";
print "
print "";
print "
";" . $rss->channel('title') .
" ";
# print titles and URLs of news items
foreach my $item (@{$rss->{'items'}})
{
$title = $item->{'title'};
$url = $item->{'link'};
print "$title
print "";
Several RSS feeds
/bin/wget http://www.freshmeat.net/backend/fm.rdf -O freshmeat.rdf
]]>
寮婧愯蔣浠跺i18n鐨勬敮鎸佽秺鏉ヨ秺濂戒簡錛宲hp 4.3.x錛?--enable-mbstring' '--with-iconv'鍚庢瘮杈冨ソ鐨勫悓鏃跺鐞嗕簡UTF-8鍜屽叾浠栦腑鏂囧瓧絎﹂泦鍙戝竷鐨?b style="color: black; background-color: rgb(160, 255, 255);">RSS銆?br>
闇瑕佹劅璋teve鍦≒HP榪涜杞爜鏂歸潰瀵?a >MagPieRSS榪涜鍜孹ML Hacking宸ヤ綔銆傝嚦灝戠洰鍓嶄負姝細Add to my yahoo榪樹笉鑳藉緢濂界殑澶勭悊utf-8瀛楃闆嗙殑RSS鏀惰棌銆?/p>
iconv support enabled
iconv implementation unknown
iconv library version unknown
iconv.input_encoding ISO-8859-1 ISO-8859-1
iconv.internal_encoding ISO-8859-1 ISO-8859-1
iconv.output_encoding ISO-8859-1 ISO-8859-1
Multibyte Support enabled
Japanese support enabled
Simplified chinese support enabled
Traditional chinese support enabled
Korean support enabled
Russian support enabled
Multibyte (japanese) regex support enabled
1錛夊彸杈圭殑涓鏍忥紝絎竴欏圭殑sources鏈濂借窡hobby銆佸弸鎯呴摼鎺ヤ竴鏍鳳紝鍔犱釜鍥劇墖銆?br>
2錛変竴鍫嗘绱㈡鍦ㄩ偅鍎匡紝鏈変簺涔憋紝寤鴻鍙湁涓涓紝鍏跺畠鐨勬斁鍒頒竴涓簩綰ч〉闈笂銆?br>
3錛夋妸鑱旂郴鏂瑰紡鍙奵c,鍒嗗埆鍋氭垚涓鏉℃垨涓涓浘鐗囷紝鏀懼湪鍙寵竟涓鏍忎腑錛屽叿浣撶殑鍐呭鍙互鏀懼埌浜岀駭欏甸潰涓婏紝鍥犱負鎴戣寰楀ソ璞℃病鏈夊灝戜漢浼氱粏璇昏繖浜涙枃瀛椼?br>
4錛夊鏋滃彲鑳斤紝鎶妉ilina鐨勫ご閮ㄩ摼鎺ユ眽鍖栦竴涓嬪惂錛?/p>
1 鍒犻櫎榪囬暱鐨勬憳瑕侊紝鍙互閫氳繃瀵繪壘絎?涓?
$TIMERANGE = ( $_REQUEST['hours'] ? $_REQUEST['hours']*3600 : 3600*24 ) ;
# $Id$
# XML::RSS::Parser::Lite sample
use XML::RSS::Parser::Lite;
use LWP::Simple;
my $xml = get("http://www.klogs.org/index.xml");
my $rp = new XML::RSS::Parser::Lite;
$rp->parse($xml);
print "<a href=\"".$rp->get('url')."\">" . $rp->get('title') . " - " . $rp->get('description') . "</a>\n";
print "<ul>";
for (my $i = 0; $i < $rp->count(); $i++) {
my $it = $rp->get($i);
print "<li><a href=\"" . $it->get('url') . "\">" . $it->get('title') . "</a></li>\n";
}
print "</ul>";
XML::RSS::Parser浠g爜鏍蜂緥濡備笅錛?br>
#!/usr/bin/perl -w
# $Id$
# XML::RSS::Parser sample with Iconv charset convert
use XML::RSS::Parser;
use Text::Iconv;
my $converter = Text::Iconv->new("utf-8", "gbk");
my $p = new XML::RSS::Parser;
my $feed = $p->parsefile('index.xml');
my $title = XML::RSS::Parser->ns_qualify('title',$feed->rss_namespace_uri);
# may cause error this line: print $feed->channel->children($title)->value."\n";
print "item count: ".$feed->item_count()."\n\n";
foreach my $i ( $feed->items ) {
map { print $_->name.": ".$converter->convert($_->value)."\n" } $i->children;
print "\n";
}
浠巆nblog鐨凾rackback涓簡瑙e埌浜?a >Planet RSS鑱氬悎鍣?/a>
try:
data = unicode(data, "utf8").encode("utf8")
logging.debug("Encoding: UTF-8")
except UnicodeError:
try:
data = unicode(data, "iso8859_1").encode("utf8")
logging.debug("Encoding: ISO-8859-1")
except UnicodeError:
data = unicode(data, "ascii", "replace").encode("utf8")
logging.warn("Feed wasn't in UTF-8 or ISO-8859-1, replaced " +
"all non-ASCII characters.")
瀵逛簬Planet鍜孧agPieRSS鎬ц兘鐨勪富瑕佸樊寮傚湪鏄紦瀛樻満鍒朵笂錛屽叧浜庝嬌鐢ㄧ紦瀛樻満鍒跺姞閫焀EB鏈嶅姟鍙互鍙傝冿細鍙紦瀛樼殑cms璁捐銆?/p>
MagPieRSS涓璘TF-8鍜孏BK鐨?b style="color: black; background-color: rgb(160, 255, 255);">RSS瑙f瀽鍒嗘瀽
姝e鍦⊿ocialBrain 2005騫寸殑璁ㄨ浼氫腑錛孖saac Mao鎵璇達細Blog is a 'Window', also could be a 'Bridge'錛孊log鏄釜浜?緇勭粐瀵瑰鐨勨滅獥鍙b濓紝鑰?b style="color: black; background-color: rgb(160, 255, 255);">RSS鏇存柟渚夸綘灝嗚繖浜涚獥鍙g粍鍚堣搗鏉ワ紝鎴愪負鍏墮棿鐨勨滄ˉ姊佲濓紝鏈変簡榪欐牱鐨勪腑闂村彂甯冨眰錛孊log涓嶄粎浠庡崟鐐瑰彂甯冿紝鏇村埌P2P鑷姪浼犳挱錛岃秺鏉ヨ秺鐪嬪埌浜?b style="color: black; background-color: rgb(160, 255, 255);">RSS鍦ㄧ綉緇滀紶鎾笂鐨勯噸瑕佹с?/p>
Last Modified at December 19, 2004 04:40 PM
鐩稿叧鏂囩珷:
Trackback Pings
http://www.chedong.com/cgi-bin/mt3/mt-tb.cgi/27
絎竴嬈″皾璇昅agpieRSS錛屽洜涓烘病鏈夊畨瑁卛conv鍜宮bstring錛屾墍浠ュけ璐ヤ簡錛屼粖澶╁湪鏈嶅姟鍣ㄤ笂瀹夎浜唅conv鍜宮tstring鐨勬敮鎸侊紝鎴戜粖澶╀粩緇嗙湅浜嗕竴涓媗ilina涓殑rss_fetch鐨勭敤娉曪細鏈閲嶈鐨勬槸鍒跺畾RSS鐨勮緭鍑烘牸寮忎負'MAGPIE_OU... [Read More]
鐪嬪埌涓綃?a rel="nofollow">浠嬬粛 lilina 鐨勬枃绔?/a>鍚庡氨鑷繁瀹夎浜嗕竴涓?/a>璇曚簡涓嬨?a rel="nofollow">lilina 鏄竴涓敤 PHP 璇?[Read More]
鍦–NBLOG涓婃惌寤轟簡Lilina RSS鑱氬悎鍣?/a>錛岃鍚勪綅蹇楁効鑰呭皢鍚勮嚜緗戝織鎴栬呭拰涓巆nblog鐩稿叧涓撴爮鐨?b style="color: black; background-color: rgb(160, 255, 255);">RSS鎻愪氦緇欐垜 鈥?鐩存帴鍦ㄨ瘎璁轟腑鍥炲鍗沖彲銆?
鎺ㄥ箍浣跨敤RSS鑱氬悎宸ュ叿涓昏鐨勭洰鐨? . [Read More]
鐩存帴灝嗕互涓嬭鍙ュ姞鍏ュ埌 index.php 澶撮儴鍗沖彲錛孡ILINA涓綘 .
[Read More]
鍒嗙被绱㈠紩錛?棣栭〉緙虹渷鏈夋寜鏈堝綊妗g殑绱㈠紩錛屾病鏈夊垎綾葷洰褰曠殑绱㈠紩錛岀湅浜嗘墜鍐岄噷闈篃娌℃湁鍏蜂綋鐨勫弬鏁板畾涔夛紝鍙ソ鐩存帴鐪婼OURCE錛氬皾璇曠潃鎶奙onthly鏀規垚Category錛屽眳鐒舵垚浜?:-) 榪樺埌浜哅ovable Style鐨凪T鏍峰紡绔欙紝... [Read More]
Comments
紼嶅井鏀逛簡涓鐐筓I銆?br>
濡傛灉浣犺兘鏀硅繘瀹冿紝閭e氨濂戒簡銆?/p>
rss鏈潵灝卞湪緗戜笂錛屼綘鑱氬悎瀹冨湪浣犵殑緗戦〉涓婁笉浠呮崯瀹充簡浣犺嚜宸變富欏電殑璐ㄩ噺錛岃屼笖榪鋒儜浜嗘悳绱㈠紩鎿庯紝閫犳垚浣犵棝鏂ョ殑鈥滈棬鎴風綉绔欐崯瀹沖垱浣滅儹鎯呪濈殑鏁堟灉銆傝繕鏄笉瑕佽仛鍚堢殑濂斤紒
]]>History
Required Modules
perl -MCPAN -e "install XML::Parser"
perl -MCPAN -e "install XML::RSS"
ppm install XML-Parser
rss2html.pl
Get the source
This script converts an RSS file on the Web or local file system to HTML.
The first public version of RSS, 0.9, includes basic headline information. Below is an example RSS file for Freshmeat.net, a popular news site for Linux software:
<?xml version="1.0"?> |
The first major element is channel
which contains
the following elements:
title
- the title of the channel
link
- the link to the channel Web site
description
- short description of the channel
An RSS channel may also contain an image
element as in the example above which contains the following elements:
title
- the text describing the image
url
- the URL of the image
link
- the URL that the image is linked to
The item
element contains the real channel
content which is comprised of a title
and a
link
element. An RSS file may contain up to
15 items.
An RSS 0.9 file may alternatively contain a textinput
element which allows users to type a string into a HTML text input field and
submit it via the HTTP GET method to the URL specified in the
link
element.
Next, we will examine RSS 0.91 which was released by Netscape in July of 1999.
The latest version of RSS added a few new elements. Below is a sample RSS file from XML.com, an excellent XML resource site:
<?xml version="1.0"?> |
Notice that there are more descriptive elements for the channel, image, amd items elements. These are referred to as "fat elements" because they contain a more detailed description of each channel item.
![]() |
Now that you've had a change to glance at two RSS examples, it's time to introduct the XML::RSS module. XML::RSS is a subclass of XML::Parser, a Perl module maintained by Clark Cooper that utilizes James Clark's Expat C library. XML::RSS was developed to simplify the task of manipulating and parsing RSS files. A deep understanding of XML is not a prerequisite for using XML::RSS since the XML details are hidden inside the class interface.
While XML::RSS is capable of creating RSS files, we will be
focusing on parsing existing RSS files in this column. You can read
more about the capabilities of XML::Parser in the module's
documentation or by typing:
perldoc XML::RSS
Well, let's look at the code shall we? Lines 16-17 load the XML::RSS and LWP::Simple modules. We've already talked about XML::RSS in brief, but what does LWP::Simple do? Good question! The answer is simple (puns intended). It's a procedural interface for interacting with a Web server. It's also the little cousin of LWP::UserAgent, a fuller object oriented interface. We'll be using one of the library's subroutines later in the code to fetch an RSS file from the Web.
In lines 20-21 we initialize two variables that we're going to use later.
Line 25 starts the main
code body. The first thing we do is verify that the user
typed exactly one command-line parameter. This parameter is then assigned
to the $arg
variable in
line 28.
Next we create a new instance of the XML::RSS class and assign the
reference to the $rss
variable on
line 31.
Now we must determine whether the command-line parameter the user
entered is an HTTP URL or a file on the local file system
(lines 34-46). On
line 34, we us a
regular expression to look for the characters http:
.
If the command-line argument starts with these characters, we can safely
assume that the user intends to retrieve an RSS file from a Web server.
On line 35 we pass the
argument to the get()
function, which is a part of
LWP::Simple, and assign the results to the $content
variable. On line 36 we call
die()
if $content
is empty. If this happens,
it means there was an error retrieving the RSS file. If the RSS file
was downloaded successfully, $rss->parse($content)
is called
which parses the RSS file and stores the results in the object's internal
structure (line 38).
If the command-line argument does not contain the http:
characters, we assume the argument is a file instead of a URL on
lines 41-46. The
first thing we do is assign the value of $arg
to the $file
variable and test for the existence of
the file (lines 42-43).
Then we call $rss->parsefile($file)
(line 45), which parses
the RSS file and stores the results in the object's internal structure.
The parsefile()
method parses a file, whereas the
parse()
method parses the string that's passed to it.
Lastly, we call the print_html
subroutine on
line 49, which converts
the RSS object in nicely formatted HTML.
As you examine this subroutine, you will begin to understand
the internal structure of the XML::RSS object. The critical portion
of the subroutine is contained on
lines 76-79. In this
foreach
loop, we iterate over each of the RSS items.
Next, let's take a look at rss2html.pl in action.
I've added the following cron jobs that run once per hour on the Webreference server (Scheduler is the NT counterpart):
rss2html.pl http://slashdot.org/slashdot.rdf > slashdot.html
rss2html.pl http://freshmeat.net/backend/fm.rdf > freshmeat.html
rss2html.pl http://www.linuxtoday.com/backend/my-netscape.rdf > linuxtoday.html
rss2html.pl http://www.xml.com/xml/news.rdf > xmlnews.html
rss2html.pl http://www.perlxml.com/rdf/moperl.rdf > mop.html
The commands above fetch the RSS files off the Web and convert them to HTML. Using Server-Side Includes (SSI), I've included the results below:
|
|
|
![]() |
Well, we've shown in this column that Perl can really pack a wallop in a short amount of code. With rss2html.pl, anyone can automatically add a news feed to their Web site.
For more information on RSS, you might try visiting the following sites:
|
Level: Introductory |
|
13 Nov 2002
RSS is one of the most successful XML services ever. Despite its chaotic roots, it has become the community standard for exchanging content information across Web sites. Python is an excellent tool for RSS processing, and Mike Olson and Uche Ogbuji introduce a couple of modules available for this purpose.
RSS is an abbreviation with several expansions: "RDF Site Summary," "Really Simple Syndication," "Rich Site Summary," and perhaps others. Behind this confusion of names is an astonishing amount of politics for such a mundane technological area. RSS is a simple XML format for distributing summaries of content on Web sites. It can be used to share all sorts of information including, but not limited to, news flashes, Web site updates, event calendars, software updates, featured content collections, and items on Web-based auctions.
RSS was created by Netscape in 1999 to allow content to be gathered from many sources into the Netcenter portal (which is now defunct). The UserLand community of Web enthusiasts became early supporters of RSS, and it soon became a very popular format. The popularity led to strains over how to improve RSS to make it even more broadly useful. This strain led to a fork in RSS development. One group chose an approach based on RDF, in order to take advantage of the great number of RDF tools and modules, and another chose a more stripped-down approach. The former is called RSS 1.0, and the latter RSS 0.91. Just last month the battle flared up again with a new version of the non-RDF variant of RSS, which its creators are calling "RSS 2.0."
RSS 0.91 and 1.0 are very popular, and used in numerous portals and Web logs. In fact, the blogging community is a great user of RSS, and RSS lies behind some of the most impressive networks of XML exchange in existence. These networks have grown organically, and are really the most successful networks of XML services in existence. RSS is a XML service by virtue of being an exchange of XML information over an Internet protocol (the vast majority of RSS exchange is simple HTTP GET of RSS documents). In this article, we introduce just a few of the many Python tools available for working with RSS. We don't provide a technical introduction to RSS, because you can find this in so many other articles (see Resources). We recommend first that you gain a basic familiarity with RSS, and that you understand XML. Understanding RDF is not required.
[We consider RSS an 'XML service' rather than a 'Web service' due to the use of XML descriptions but the lack of use of WSDL. -- Editors]
RSS.py
Mark Nottingham's RSS.py is a Python library for RSS processing. It is
very complete and well-written. It requires Python 2.2 and PyXML 0.7.1.
Installation is easy; just download the Python file from Mark's home
page and copy it to somewhere in your PYTHONPATH
.
Most users of RSS.py need only concern themselves with two classes it provides: CollectionChannel
and TrackingChannel
. The latter seems the more useful of the two. TrackingChannel
is a data structure that contains all the RSS data indexed by the key of each item. CollectionChannel
is a similar data structure, but organized more as RSS documents
themselves are, with the top-level channel information pointing to the
item details using hash values for the URLs. You will probably use the
utility namespace declarations in the RSS.ns
structure. Listing 1
is a simple script that downloads and parses an RSS feed for Python
news, and prints out all the information from the various items in a
simple listing.
|
We start by creating a TrackingChannel
instance, and then populate it with data parsed from the RSS feed at http://www.python.org/channews.rdf
.
RSS.py uses tuples as the property names for RSS data. This may seem an
unusual approach to those not used to XML processing techniques, but it
is actually a very useful way of being very precise about what was in
the original RSS file. In effect, an RSS 0.91 title
element is not considered to be equivalent to an RSS 1.0 one. There is
enough data for the application to ignore this distinction, if it
likes, by ignoring the namespace portion of each tuple; but the basic
API is wedded to the syntax of the original RSS file, so that this
information is not lost. In the code, we use this property data to
gather all the items from the news feed for display. Notice that we are
careful not to assume which properties any particular item might have.
We retrieve properties using the safe form as seen in the code below.
|
Which provides a default value if the property is not found, rather than this example.
|
This precaution is necessary because you never know what elements are used in an RSS feed. Listing 2shows the output from Listing 1.
|
Of course, you would expect somewhat different output because the
news items will have changed by the time you try it. The RSS.py channel
objects also provide methods for adding and modifying RSS information.
You can write the result back to RSS 1.0 format using the output()
method. Try this out by writing back out the information parsed in Listing 1. Kick off the script in interactive mode by running: python -i listing1.py
. At the resuting Python prompt, run the following example.
|
The result is an RSS 1.0 document printed out. You must have RSS.py,
version 0.42 or more recent for this to work. There is a bug in the output()
method in earlier versions.
rssparser.py
Mark Pilgrim offers another module for RSS file parsing. It doesn't
provide all the features and options that RSS.py does, but it does
offer a very liberal parser, which deals well with all the confusing
diversity in the world of RSS. To quote from the rssparser.py page:
You see, most RSS feeds suck. Invalid characters, unescaped ampersands (Blogger feeds), invalid entities (Radio feeds), unescaped and invalid HTML (The Register's feed most days). Or just a bastardized mix of RSS 0.9x elements with RSS 1.0 elements (Movable Type feeds).
Then
there are feeds, like Aaron's feed, which are too bleeding edge. He
puts an excerpt in the description element but puts the full text in
the content:encoded element (as CDATA). This is valid RSS 1.0, but
nobody actually uses it (except Aaron), few news aggregators support
it, and many parsers choke on it. Other parsers are confused by the new
elements (guid) in RSS 0.94 (see Dave Winer's feed for an example). And
then there's Jon Udell's feed, with the fullitem
element that he just sort of made up.
It's funny to consider this in the light of the fact that XML and Web services are supposed to increase interoperability. Anyway, rssparser.py is designed to deal with all the madness.
Installing rssparser.py is also very easy. You download the Python
file (see Resources), rename it from "rssparser.py.txt" to
"rssparser.py", and copy it to your PYTHONPATH
. I also
suggest getting the optional timeoutsocket module which improves the
timeout behavior of socket operations in Python, and thus can help
getting RSS feeds less likely to stall the application thread in case
of error.
Listing 3 is a script that is the equivalent of Listing 1, but using rssparser.py, rather than RSS.py.
|
As you can see, the code is much simpler. The trade-off between RSS.py and rssparser.py is largely that the former has more features, and maintains more syntactic information from the RSS feed. The latter is simpler, and a more forgiving parser (the RSS.py parser only accepts well-formed XML).
The output should be the same as in Listing 2.
Conclusion
There are many Python tools for RSS, and we don't have space to cover
them all. Aaron Swartz's page of RSS tools is a good place to start
looking if you want to explore other modules out there. RSS is easy to
work with in Python, because of all the great modules available for it.
The modules hide all the chaos brought about by the history and
popularity of RSS. If your XML services needs mostly involve the
exchange of descriptive information for Web sites, we highly recommend
using the most successful XML service technology in employment.
Next month, we will explain how to use e-mail packages for Python for writing Web services over SMTP.
About the authors![]() |
|
This is a "universal" feed parser, suitable for reading syndicated feeds as produced by weblogs, news sites, wikis, and many other types of sites. It handles Atom feeds, CDF, and the nine different versions of RSS.
This project is now hosted at SourceForge. Please check there for updates. This page contains old news and is no longer updated. (2004-06-21)
浣?鑰咃細 杞︿笢
鏈鍚庢洿鏂幫細2002-08-30 13:18:41
鐗堟潈澹版槑錛氬彲浠ヤ換鎰忚漿杞斤紝杞澆鏃惰鍔″繀鏍囨槑鍘熷鍑哄鍜屼綔鑰呬俊鎭?br>
姒傝堪錛?b style="color: black; background-color: rgb(255, 255, 102);">CVS鏄竴涓狢/S緋葷粺錛屽涓紑鍙戜漢鍛橀氳繃涓涓腑蹇冪増鏈帶鍒剁郴緇熸潵璁板綍鏂囦歡鐗堟湰錛屼粠鑰岃揪鍒頒繚璇佹枃浠跺悓姝ョ殑鐩殑銆?
CVS鏈嶅姟鍣紙鏂囦歡鐗堟湰搴擄級
/
| \
錛堢増 鏈?鍚?姝ワ級
/
| \
寮鍙戣? 寮鍙戣? 寮鍙戣?
浠ヤ笅鏄湰鏂囦富瑕佸唴瀹癸細寮鍙戜漢鍛樺彲浠ヤ富瑕佹寫閫?, 6鐪嬪氨鍙互浜嗭紝CVS鐨勭鐞嗗憳鍒欐洿闇瑕佹噦鐨勬洿澶氫竴浜?
涓涓郴緇?0%鐨勫姛鑳藉線寰鑳藉婊¤凍80%鐨勯渶姹傦紝CVS涔熶笉渚嬪錛屼互涓嬫槸CVS鏈甯哥敤鐨勫姛鑳斤紝鍙兘鐢ㄥ埌鐨勮繕涓嶅埌瀹冨叏閮ㄥ懡浠ら夐」鐨?0%錛屾洿澶氱殑鍔熻兘璇峰湪瀹為檯搴旂敤榪囩▼涓綋浼氾紝瀛︿範榪囩▼涓簲璇ユ槸鐢ㄥ灝戯紝瀛﹀灝戯紝鐢ㄥ埌浜嗗啀瀛︿篃涓嶈繜銆?
CVS鐜鍒濆鍖?br>
============
鐜璁劇疆錛氭寚瀹?b style="color: black; background-color: rgb(255, 255, 102);">CVS搴撶殑璺緞CVSROOT
tcsh
setenv CVSROOT /path/to/cvsroot
bash
CVSROOT=/path/to/cvsroot ; export CVSROOT
鍚庨潰榪樻彁鍒拌繙紼?b style="color: black; background-color: rgb(255, 255, 102);">CVS鏈嶅姟鍣ㄧ殑璁劇疆錛?br>
CVSROOT=:ext:$USER@test.server.address#port:/path/to/cvsroot CVS_RSH=ssh; export
CVSROOT CVS_RSH
鍒濆鍖栵細CVS鐗堟湰搴撶殑鍒濆鍖栥?br>
cvs init
涓涓」鐩殑棣栨瀵煎叆
cvs import -m "write some comments here" project_name vendor_tag
release_tag
鎵ц鍚庯細浼氬皢鎵鏈夋簮鏂囦歡鍙婄洰褰曞鍏ュ埌/path/to/cvsroot/project_name鐩綍涓?br>
vender_tag: 寮鍙戝晢鏍囪
release_tag: 鐗堟湰鍙戝竷鏍囪
欏圭洰瀵煎嚭錛氬皢浠g爜浠?b style="color: black; background-color: rgb(255, 255, 102);">CVS搴撻噷瀵煎嚭
cvs checkout project_name
cvs 灝嗗垱寤簆roject_name鐩綍錛屽茍灝嗘渶鏂扮増鏈殑婧愪唬鐮佸鍑哄埌鐩稿簲鐩綍涓傝繖涓猚heckout鍜孷irvual
SourceSafe涓殑check out涓嶆槸涓涓蹇碉紝鐩稿浜嶸irvual SourceSafe鐨刢heck
out鏄?b style="color: black; background-color: rgb(255, 255, 102);">cvs update錛?check in鏄?b style="color: black; background-color: rgb(255, 255, 102);">cvs commit銆?/i>
CVS鐨勬棩甯鎬嬌鐢?/b>
=============
娉ㄦ剰錛氱涓嬈″鍑轟互鍚庯紝灝變笉鏄氳繃cvs checkout鏉ュ悓姝ユ枃浠朵簡錛岃屾槸瑕佽繘鍏ュ垰鎵?b style="color: black; background-color: rgb(255, 255, 102);">cvs checkout project_name瀵煎嚭鐨刾roject_name鐩綍涓嬭繘琛屽叿浣撴枃浠剁殑鐗堟湰鍚屾錛堟坊鍔狅紝淇敼錛屽垹闄わ級鎿嶄綔銆?/b>
灝嗘枃浠跺悓姝ュ埌鏈鏂扮殑鐗堟湰錛?br>
cvs update
涓嶅埗瀹氭枃浠跺悕錛?b style="color: black; background-color: rgb(255, 255, 102);">cvs灝嗗悓姝ユ墍鏈夊瓙鐩綍涓嬬殑鏂囦歡錛屼篃鍙互鍒跺畾鏌愪釜鏂囦歡鍚?鐩綍榪涜鍚屾
cvs update file_name
鏈濂芥瘡澶╁紑濮嬪伐浣滃墠鎴栧皢鑷繁鐨勫伐浣滃鍏ュ埌CVS搴撻噷鍓嶉兘瑕佸仛涓嬈★紝騫跺吇鎴愨滃厛鍚屾
鍚庝慨鏀光濈殑涔犳儻錛屽拰Virvual SourceSafe涓嶅悓錛?b style="color: black; background-color: rgb(255, 255, 102);">CVS閲屾病鏈夋枃浠墮攣瀹氱殑姒傚康錛屾墍鏈夌殑鍐茬獊鏄湪commit涔嬪墠瑙e喅錛屽鏋滀綘淇敼榪囩▼涓紝鏈夊叾浠栦漢淇敼騫禼ommit鍒頒簡CVS搴撲腑錛?b style="color: black; background-color: rgb(255, 255, 102);">CVS浼氶氱煡浣犳枃浠跺啿紿侊紝騫惰嚜鍔ㄥ皢鍐茬獊閮ㄥ垎鐢?br>
>>>>>>
content on cvs server
<<<<<<
content in your file
>>>>>>
鏍囪鍑烘潵錛岀敱浣犵‘璁ゅ啿紿佸唴瀹圭殑鍙栬垗銆?br>
鐗堟湰鍐茬獊涓鑸槸鍦ㄥ涓漢淇敼涓涓枃浠墮犳垚鐨勶紝浣嗚繖縐嶉」鐩鐞嗕笂鐨勯棶棰樹笉搴旇鎸囨湜鐢?b style="color: black; background-color: rgb(255, 255, 102);">CVS鏉ヨВ鍐熾?/i>
紜淇敼鍐欏叆鍒?b style="color: black; background-color: rgb(255, 255, 102);">CVS搴撻噷錛?br> cvs commit -m "write some comments here" file_name
娉ㄦ剰錛?b style="color: black; background-color: rgb(255, 255, 102);">CVS鐨勫緢澶氬姩浣滈兘鏄氳繃cvs commit榪涜鏈鍚庣‘璁ゅ茍淇敼鐨勶紝鏈濂芥瘡嬈″彧淇敼涓涓枃浠躲傚湪紜鐨勫墠錛岃繕闇瑕佺敤鎴峰~鍐欎慨鏀規敞閲婏紝浠ュ府鍔╁叾浠栧紑鍙戜漢鍛樹簡瑙d慨鏀圭殑鍘熷洜銆傚鏋滀笉鐢ㄥ啓-m
"comments"鑰岀洿鎺ョ‘璁cvs commit file_name` 鐨勮瘽錛?b style="color: black; background-color: rgb(255, 255, 102);">cvs浼氳嚜鍔ㄨ皟鐢ㄧ郴緇熺己鐪佺殑鏂囧瓧緙栬緫鍣?涓鑸槸vi)瑕佹眰浣犲啓鍏ユ敞閲娿?br>
娉ㄩ噴鐨勮川閲忓緢閲嶈錛氭墍浠ヤ笉浠呭繀欏昏鍐欙紝鑰屼笖蹇呴』鍐欎竴浜涙瘮杈冩湁鎰忎箟鐨勫唴瀹癸細浠ユ柟渚垮叾浠栧紑鍙戜漢鍛樿兘澶熷緢濂界殑鐞嗚В
涓嶅ソ鐨勬敞閲婏紝寰堥毦璁╁叾浠栫殑寮鍙戜漢鍛樺揩閫熺殑鐞嗚В錛氭瘮濡傦細 -m
"bug fixed" 鐢氳嚦 -m ""
濂界殑娉ㄩ噴錛岀敋鑷沖彲浠ョ敤涓枃: -m "鍦ㄧ敤鎴鋒敞鍐岃繃紼嬩腑鍔犲叆浜咵mail鍦板潃鏍¢獙"
淇敼鏌愪釜鐗堟湰娉ㄩ噴錛氭瘡嬈″彧紜涓涓枃浠跺埌CVS搴撻噷鏄竴涓緢濂界殑涔犳儻錛屼絾闅懼厤鏈夋椂鍊欏繕浜嗘寚瀹氭枃浠跺悕錛屾妸澶氫釜鏂囦歡浠ュ悓鏍鋒敞閲奵ommit鍒?b style="color: black; background-color: rgb(255, 255, 102);">CVS搴撻噷浜嗭紝浠ヤ笅鍛戒護鍙互鍏佽浣犱慨鏀規煇涓枃浠舵煇涓増鏈殑娉ㄩ噴錛?br>
cvs admin -m 1.3:"write some comments here" file_name
娣誨姞鏂囦歡
鍒涘緩濂芥柊鏂囦歡鍚庯紝姣斿錛歵ouch new_file
cvs add new_file
娉ㄦ剰錛氬浜庡浘鐗囷紝Word鏂囨。絳夐潪綰枃鏈殑欏圭洰錛岄渶瑕佷嬌鐢?b style="color: black; background-color: rgb(255, 255, 102);">cvs
add -b閫夐」錛屽惁鍒欐湁鍙兘鍑虹幇鏂囦歡琚牬鍧忕殑鎯呭喌
姣斿錛?b style="color: black; background-color: rgb(255, 255, 102);">cvs add -kb new_file.gif
鐒跺悗紜淇敼騫舵敞閲?
cvs ci -m "write some comments here"
鍒犻櫎鏂囦歡錛?br>
灝嗘煇涓簮鏂囦歡鐗╃悊鍒犻櫎鍚庯紝姣斿錛歳m file_name
cvs rm file_name
鐒跺悗紜淇敼騫舵敞閲?br>
cvs ci -m "write some comments here"
浠ヤ笂闈㈠墠2姝ュ悎騫剁殑鏂規硶涓猴細
cvs rm -f file_name
cvs ci -m "why delete file"
娉ㄦ剰錛氬緢澶?b style="color: black; background-color: rgb(255, 255, 102);">cvs鍛戒護閮芥湁緙╁啓褰㈠紡錛歝ommit=>ci; update=>up; checkout=>co; remove=>rm;
娣誨姞鐩綍錛?br>
cvs add dir_name
鏌ョ湅淇敼鍘嗗彶錛?b style="color: black; background-color: rgb(255, 255, 102);">cvs log file_name
cvs history file_name
鏌ョ湅褰撳墠鏂囦歡涓嶅悓鐗堟湰鐨勫尯鍒?br>
cvs diff -r1.3 -r1.5 file_name
鏌ョ湅褰撳墠鏂囦歡錛堝彲鑳藉凡緇忎慨鏀逛簡錛夊拰搴撲腑鐩稿簲鏂囦歡鐨勫尯鍒?br>
cvs diff file_name
cvs鐨剋eb鐣岄潰鎻愪緵浜嗘洿鏂逛究鐨勫畾浣嶆枃浠朵慨鏀瑰拰姣旇緝鐗堟湰鍖哄埆鐨勬柟娉曪紝鍏蜂綋瀹夎璁劇疆璇風湅鍚庨潰鐨刢vsweb浣跨敤
姝g‘鐨勯氳繃CVS鎭㈠鏃х増鏈殑鏂規硶錛?br>
濡傛灉鐢?b style="color: black; background-color: rgb(255, 255, 102);">cvs update -r1.2 file.name
榪欎釜鍛戒護鏄粰file.name鍔犱竴涓猄TICK TAG錛?"1.2"
錛岃櫧鐒朵綘鐨勬湰鎰忓彧鏄兂灝嗗畠鎭㈠鍒?.2鐗堟湰
姝g‘鐨勬仮澶嶇増鏈殑鏂規硶鏄細cvs update -p -r1.2 file_name >file_name
濡傛灉涓嶅皬蹇冨凡緇忓姞鎴怱TICK TAG鐨勮瘽錛氱敤cvs update -A 瑙e喅
縐誨姩鏂囦歡錛氭枃浠墮噸鍛藉悕
cvs閲屾病鏈?b style="color: black; background-color: rgb(255, 255, 102);">cvs move鎴?b style="color: black; background-color: rgb(255, 255, 102);">cvs rename錛屽洜涓鴻繖涓や釜鎿嶄綔鏄厛cvs remove
old_file_name錛岀劧鍚?b style="color: black; background-color: rgb(255, 255, 102);">cvs add new_file_name瀹炵幇鐨勩?/p>
鍒犻櫎錛岀Щ鍔ㄧ洰褰曪細
鏈鏂逛究鐨勬柟娉曟槸璁╃鐞嗗憳鐩存帴縐誨姩錛屽垹闄VSROOT閲岀浉搴旂洰褰曪紙鍥犱負CVS涓涓」鐩笅鐨勫瓙鐩綍閮芥槸鐙珛鐨勶紝縐誨姩鍒?CVSROOT鐩綍涓嬮兘鍙互浣滀負鏂扮殑鐙珛欏圭洰錛氬ソ姣斾竴棰楁爲錛屽叾瀹炵爫涓嬩換鎰忎竴鏋濋兘鑳界嫭绔嬪瓨媧伙級錛屽鐩綍榪涜浜嗕慨鏀瑰悗錛岃姹傚叾寮鍙戜漢鍛橀噸鏂板鍑洪」鐩?b style="color: black; background-color: rgb(255, 255, 102);">cvs
checkout project_name 鎴栬呯敤cvs update -dP鍚屾銆?/p>
CVS Branch錛氶」鐩鍒嗘敮鍚屾寮鍙?br> =============================
紜鐗堟湰閲岀▼紕戯細澶氫釜鏂囦歡鍚勮嚜鐗堟湰鍙蜂笉涓鏍鳳紝欏圭洰鍒頒竴瀹氶樁孌碉紝鍙互緇欐墍鏈夋枃浠剁粺涓鎸囧畾涓涓樁孌甸噷紼嬬鐗堟湰鍙鳳紝鏂逛究浠ュ悗鎸夌収榪欎釜闃舵閲岀▼紕戠増鏈彿瀵煎嚭欏圭洰錛屽悓鏃朵篃鏄」鐩殑澶氫釜鍒嗘敮寮鍙戠殑鍩虹銆?br> cvs tag release_1_0
寮濮嬩竴涓柊鐨勯噷紼嬬錛?br> cvs commit -r 2 鏍囪鎵鏈夋枃浠跺紑濮嬭繘鍏?.x鐨勫紑鍙?/p>
娉ㄦ剰錛?b style="color: black; background-color: rgb(255, 255, 102);">CVS閲岀殑revsion鍜岃蔣浠跺寘鐨勫彂甯冪増鏈彲浠ユ病鏈夌洿鎺ョ殑鍏崇郴銆備絾鎵鏈夋枃浠朵嬌鐢ㄥ拰鍙戝竷鐗堟湰涓鑷寸殑鐗堟湰鍙鋒瘮杈冩湁鍔╀簬緇存姢銆?/i>
鍦ㄥ紑鍙戦」鐩殑2.x鐗堟湰鐨勬椂鍊欏彂鐜?.x鏈夐棶棰橈紝浣?.x鍙堜笉鏁㈢敤錛屽垯浠庡厛鍓嶆爣璁扮殑閲岀▼紕戯細release_1_0瀵煎嚭涓涓垎鏀痳elease_1_0_patch
cvs rtag -b -r release_1_0 release_1_0_patch proj_dir
涓浜涗漢鍏堝湪鍙﹀涓涓洰褰曚笅瀵煎嚭release_1_0_patch榪欎釜鍒嗘敮錛氳В鍐?.0涓殑绱фラ棶棰橈紝
cvs checkout -r release_1_0_patch
鑰屽叾浠栦漢鍛樹粛鏃у湪欏圭洰鐨勪富騫插垎鏀?.x涓婂紑鍙?/p>
鍦╮elease_1_0_patch涓婁慨姝i敊璇悗錛屾爣璁頒竴涓?.0鐨勯敊璇慨姝g増鏈彿
cvs tag release_1_0_patch_1
濡傛灉2.0璁や負榪欎簺閿欒淇敼鍦?.0閲屼篃闇瑕侊紝涔熷彲浠ュ湪2.0鐨勫紑鍙戠洰褰曚笅鍚堝茍release_1_0_patch_1涓殑淇敼鍒板綋鍓嶄唬鐮佷腑錛?br> cvs update -j release_1_0_patch_1
CVS鐨勮繙紼嬭璇侊細閫氳繃SSH榪滅▼璁塊棶CVS
================================
浣跨敤cvs鏈韓鐨勮繙紼嬭璇佸緢楹葷儲,闇瑕佸畾涔夋湇鍔″櫒鍜岀敤鎴風粍錛岀敤鎴峰悕錛岃緗瘑鐮佺瓑錛岃屼笖涓嶅畨鍏紝鍥犳鍜岀郴緇熸湰鍦板笎鍙瘋璇佸茍閫氳繃SSH浼犺緭鏄瘮杈冨ソ鐨勫姙娉曪紝閫氳繃鍦ㄥ鎴鋒満鐨?etc/profile閲岃緗竴涓嬪唴瀹癸細
CVSROOT=:ext:$USER@test.server.address#port:/path/to/cvsroot CVS_RSH=ssh; export
CVSROOT CVS_RSH
鎵鏈夊鎴鋒満鎵鏈夋湰鍦扮敤鎴烽兘鍙互鏄犲皠鍒?b style="color: black; background-color: rgb(255, 255, 102);">CVS鏈嶅姟鍣ㄧ浉搴斿悓鍚嶅笎鍙蜂簡銆?br>
濡傛灉CVS鎵鍦ㄦ湇鍔″櫒鐨凷SH绔彛涓嶅湪緙虹渷鐨?2錛屾垨鑰呭拰瀹㈡埛绔笌CVS鏈嶅姟鍣ㄧSSH緙虹渷绔彛涓嶄竴鑷達紝鏈夋椂鍊欒緗簡錛?br>
:ext:$USER@test.server.address#port:/path/to/cvsroot
浠嶇劧涓嶈錛屾瘮濡傛湁浠ヤ笅閿欒淇℃伅錛?br>
ssh: test.server.address#port: Name or service not known
cvs [checkout aborted]: end of file from server (consult above messages if any)
瑙e喅鐨勬柟娉曟槸鍋氫竴涓剼鏈寚瀹氱鍙h漿鍚戯紙涓嶈兘浣跨敤alias錛屼細鍑烘壘涓嶅埌鏂囦歡閿欒錛夛細
鍒涘緩涓涓?usr/bin/ssh_cvs鏂囦歡錛?br>
#!/usr/bin/sh
/path/to/ssh -p 34567 "$@"
鐒跺悗錛歝hmod +x /usr/bin/ssh_cvs
騫禖VS_RSH=ssh_cvs; export CVS_RSH
娉ㄦ剰錛歱ort鏄寚鐩稿簲鏈嶅姟鍣⊿SH鐨勭鍙o紝涓嶆槸cvs pserver鐨勭鍙?br>
CVSWEB錛氭彁楂樼▼搴忓憳姣旇緝鏂囦歡淇敼鏁堢巼
================================
CVSWEB灝辨槸CVS鐨刉EB鐣岄潰錛屽彲浠ュぇ澶ф彁楂樼▼搴忓憳瀹氫綅淇敼鐨勬晥鐜?
浣跨敤鐨勬牱渚嬪彲浠ョ湅錛?a >http://www.freebsd.org/cgi/cvsweb.cgi
CVSWEB鐨勪笅杞斤細CVSWEB浠庢渶鍒濈殑鐗堟湰宸茬粡婕斿寲鍑哄緢澶氬姛鑳界晫闈㈡洿涓板瘜鐨勭増鏈紝榪欎釜鏄釜浜烘劅瑙夎寰楀畨瑁呰緗瘮杈冩柟渚跨殑錛?br>
http://www.spaghetti-code.de/software/linux/cvsweb/
涓嬭澆瑙e寘錛?br>
tar zxf cvsweb.tgz
鎶婇厤緗枃浠禼vsweb.conf鏀懼埌瀹夊叏鐨勫湴鏂癸紙姣斿鍜宎pache鐨勯厤緗斁鍦ㄥ悓涓涓洰褰曚笅錛夛紝
淇敼錛歝vsweb.cgi璁〤GI鎵懼埌閰嶇疆鏂囦歡錛?br>
$config = $ENV{'CVSWEB_CONFIG'} || '/path/to/apache/conf/cvsweb.conf';
杞埌/path/to/apache/conf涓嬪茍淇敼cvsweb.conf錛?/p>
CVSWEB鍙笉鑳介殢渚垮紑鏀劇粰鎵鏈夌敤鎴鳳紝鍥犳闇瑕佷嬌鐢╓EB鐢ㄦ埛璁よ瘉錛?br>
鍏堢敓鎴?passwd:
/path/to/apache/bin/htpasswd -c cvsweb.passwd user
淇敼httpd.conf: 澧炲姞
<Directory "/path/to/apache/cgi-bin/cvsweb/">
AuthName "CVS Authorization"
AuthType Basic
AuthUserFile /path/to/cvsweb.passwd
require valid-user
</Directory>
CVS TAGS: who? when?
====================
灝?Id$ 鍔犲湪紼嬪簭鏂囦歡寮澶寸殑娉ㄩ噴閲屾槸涓涓緢濂界殑涔犳儻錛?b style="color: black; background-color: rgb(255, 255, 102);">cvs鑳藉鑷姩瑙i噴鏇存柊鍏朵腑鐨勫唴瀹規垚錛歠ile_name
version time user_name 鐨勬牸寮忥紝姣斿錛歝vs_card.txt,v 1.1 2002/04/05
04:24:12 chedong Exp錛屽彲浠ヨ繖浜涗俊鎭簡瑙f枃浠剁殑鏈鍚庝慨鏀逛漢鍜屼慨鏀規椂闂?br>
鍑犱釜甯哥敤鐨勭己鐪佹枃浠訛細
default.php
<?php
/*
* Copyright (c) 2002 Company Name.
* $Header$
*/
?>
====================================
Default.java: 娉ㄦ剰鏂囦歡澶翠竴鑸敞閲婄敤 /* 寮濮?JAVADOC娉ㄩ噴鐢?/**
寮濮嬬殑鍖哄埆
/*
* Copyright (c) 2002 Company Name.
* $Header$
*/
package com.netease;
import java.io;
/**
* comments here
*/
public class Default {
/**
*
* @param
* @return
*/
public toString() {
}
}
====================================
default.pl:
#!/usr/bin/perl -w
# Copyright (c) 2002 Company Name.
# $Header$
# file comments here
use strict;
CVS vs VSS銆
===========
CVS娌℃湁鏂囦歡閿佸畾妯″紡錛孷SS鍦╟heck out鍚屾椂錛屽悓鏃惰褰曚簡鏂囦歡琚鍑鴻呴攣瀹氥?
CVS鏄痷pdate commit錛?VSS鏄痗heck out check in
鍦?b style="color: black; background-color: rgb(255, 255, 102);">CVS涓紝鏍囪鑷姩鏇存柊鍔熻兘緙虹渷鏄墦寮鐨勶紝榪欐牱涔熷甫鏉ヤ竴涓綔鍦ㄧ殑闂錛屽氨鏄笉鐢?kb鏂瑰紡娣誨姞binary鏂囦歡鐨勮瘽鍦?b style="color: black; background-color: rgb(255, 255, 102);">cvs鑷姩鏇存柊鏃跺彲鑳戒細瀵艱嚧鏂囦歡澶辨晥銆?
Virsual SourceSafe涓繖涓姛鑳界О涔嬩負Keyword Explaination錛岀己鐪佹槸鍏抽棴鐨勶紝闇瑕侀氳繃OPITION鎵撳紑錛屽茍鎸囧畾闇瑕佽繘琛屾簮鏂囦歡鍏抽敭璇嶆壂鎻忕殑綾誨瀷錛?.txt,*.java,*.html...
瀵逛簬Virsual
SourceSafe鍜?b style="color: black; background-color: rgb(255, 255, 102);">CVS閮介氱敤鐨凾AG鏈夛細
$Header$
$Author$
$Date$
$Revision$
灝介噺浣跨敤閫氱敤鐨勫叧閿瘝淇濊瘉浠g爜鍦?b style="color: black; background-color: rgb(255, 255, 102);">CVS鍜孷SS閮借兘鏂逛究鐨勮窡韙?
銆
鐩稿叧璧勬簮錛?/p>
CVS HOME錛?br> http://www.cvshome.org
CVS FAQ錛?br>
http://www.loria.fr/~molli/cvs-index.html
鐩稿叧緗戠珯:
http://directory.google.com/Top/Computers/Software/Configuration_Management/Tools/Concurrent_Versions_System/
CVS 鍏嶈垂涔?
http://cvsbook.red-bean.com/
CVS 鍛戒護鐨勯熸煡鍗$墖錛?br> http://www.refcards.com/about/cvs.html
鎽樿嚜錛?a target="_blank">http://www.chedong.com/tech/cvs_card.html
|
銆銆榪欐潯鍛戒護鍒涘緩浜嗕竴涓悕涓簃yaccount鐨勬櫘閫歎nix鐢ㄦ埛銆?
銆銆鐒跺悗鏍規嵁瀹冨垱寤轟竴涓猄amba鐢ㄦ埛錛?
|
銆銆鎴栬呮槸錛?
|
The password in Samba is not related to the unix account password.
娉ㄦ剰錛氫竴鏃︿綘鏇存柊浜?b style="color: black; background-color: rgb(255, 255, 102);">samba閰嶇疆鏂囦歡錛屼綘蹇呴』瑕侀氳繃浣跨敤/etc/init.d/samba restart (debian)鏉ラ噸璧蜂綘鐨?b style="color: black; background-color: rgb(255, 255, 102);">samba
Then in windows, use the username and samba's password to map network drive.