PEAK XOOPS - Let's make joints (1) in englishin japanese

Archive | RSS |
XOOPS : Let's make joints (1)
Poster : GIJOE on 2007-04-27 05:16:04 (7882 reads)

in englishin japanese
It is quite easy to create a joint for d3pipes.
This is a sample to get renewal announcement from HTML.

With d3pipes, all you have to do is creating a class of parse joint.

Make a class definition file under

In this document, the class is named as Simplehtml.

ClassName: D3pipesParseSimplehtml
FileName: D3pipesParseSimplehtml.class.php

Just write a method of execute() in the file.
execute() of "Parse" joint gets a string and returns array of entries.

Each entry should have 4 parameters.

'heading' : heading
'pubtime' : UnixTimestamp (Set it if you can)
'link' : URI of the article (Set it if you can)
'fingerprint' : ID of the article

With the sample joint of D3pipesParseSimplehtml, you can make a pipe like this.
(The site describe each renewal annoucement in <h2>)

 0 Fetching from outside  snoopy    (URI of the site)
10 Transfer to UTF-8     (asyoulike)  The encoding of the site
20 Parsing XML           simplehtml  #\<h2\>([^<]*)\</h2\>#iU
30 Transfer from UTF-8   (asyoulike)  Internal encoding of your site
40 Reassign              defaultlink (URI of the site)
50 Clipping into local    moduledb   86400



require_once dirname(dirname(__FILE__)).'/D3pipesParseAbstract.class.php' ;

class D3pipesParseSimplehtml extends D3pipesParseAbstract {

	function execute( $html_source , $max_entries = '' )
		$items = array() ;

		preg_match_all( $this->option , $html_source , $matches , PREG_SET_ORDER ) ;
		foreach( $matches as $match ) {
			$items[] = array(
				'headline' => $match[1] ,
				'pubtime' => time() ,
				// 'link' => '' ,
				'fingerprint' => md5( $match[1] ) ,
			) ;

		return $items ;




Related articles
Printer friendly page Send this story to a friend

Comments list

Username or e-mail:


Remember Me

Lost Password?

Register now!