<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>planet-ape&#124;blog &#187; Conveyor</title>
	<atom:link href="http://www.planet-ape.net/blog/archives/tag/conveyor/feed" rel="self" type="application/rss+xml" />
	<link>http://www.planet-ape.net/blog</link>
	<description>We Love WordPress</description>
	<lastBuildDate>Sun, 20 Nov 2011 09:36:42 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AV女優の画像を取得する（Conveyorネタ）</title>
		<link>http://www.planet-ape.net/blog/archives/570</link>
		<comments>http://www.planet-ape.net/blog/archives/570#comments</comments>
		<pubDate>Sat, 09 Feb 2008 11:10:08 +0000</pubDate>
		<dc:creator>fumix</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[rhaco]]></category>
		<category><![CDATA[Conveyor]]></category>

		<guid isPermaLink="false">http://www.planet-ape.net/archives/570</guid>
		<description><![CDATA[以前に作った「Conveyor(旧名PRhagger)で日本のAV女優一覧のRSSを取得してみる」に追加する形でそこにAV女優の画像（顔写真）を検索して追加するようなworker（filter）を作ってみました。 画像は [...]]]></description>
			<content:encoded><![CDATA[				<p>以前に作った「<a href="http://www.planet-ape.net/archives/566">Conveyor(旧名PRhagger)で日本のAV女優一覧のRSSを取得してみる</a>」に追加する形でそこにAV女優の画像（顔写真）を検索して追加するようなworker（filter）を作ってみました。<br />
				画像は<a href="http://actress.dmm.co.jp/-/top/">DMMアダルト AV女優情報</a>の検索結果をスクレイピングする形で取得します。<br />
				DMMはアフィリエイトをしているので、urlにはconfigに入力したアフィリエイトIDを追加したURLを返すようにします。</p>
				<ul class="link">
				<li><a href='http://www.planet-ape.net/wp-content/uploads/2008/02/filteravactresspict.zip' title='filteravactresspict.zip'>FilterAvActressPict.zip</a></li>
				</ul>
				<pre class="brush: php">
&lt;?php

Rhaco::import(&quot;model.FilterBase&quot;);
Rhaco::import(&quot;tag.feed.Rss20&quot;);
Rhaco::import('tag.model.SimpleTag');
Rhaco::import('network.http.Http');
Rhaco::import(&quot;network.http.Browser&quot;);
Rhaco::import(&quot;lang.StringUtil&quot;);
Rhaco::import(&quot;io.Cache&quot;);

/**
 *
 * FilterAvActressPict
 *
 * @author fumix
 * @license New BSD License
 * @copyright Copyright 2008- The Rhacophorus Project. All rights reserved.
 */
class FilterAvActressPict extends FilterBase{
    function execute($rss20)
    {
        $channel = $rss20-&gt;getChannel();
        $items =&amp; $rss20-&gt;getItem();

        $rss20_filtered = new Rss20();
		$rss20_filtered-&gt;setChannel($channel-&gt;getTitle(),
			$channel-&gt;getDescription(),
			$channel-&gt;getLink(),
			&quot;ja&quot;
		);

        foreach ($items as $item) {
            $rtn = $this-&gt;searchAV($item-&gt;getTitle());
            $av = $item-&gt;getDescription().$rtn['img'];
            $item-&gt;setDescription($av);
            $item-&gt;setLink($rtn['url']);
            $rss20_filtered-&gt;setItem($item);
        }
        return $rss20_filtered;
    }

    /**
     * searchAV
     *
     * @access protected
     * @param string $message
     */
    function searchAV($message)
    {
        $cache = new Cache();
        $parm = urlencode(StringUtil::encoding($message,StringUtil::EUC()));
        $browser = new Browser();
        //キャッシュを利用
        if($cache-&gt;get($parm)){
    	   $page = $cache-&gt;get($parm);
        }else{
        	$page = StringUtil::encoding($browser-&gt;get(&quot;http://www.dmm.co.jp/search/?category=actress&amp;analyze=V1EAAVYEUQs_&amp;redirect=1&amp;searchstr=&quot;.$parm));
        	$cache-&gt;set($parm,$page);
        }
		$tag = new SimpleTag();
		$tag-&gt;set($page);

        $tbl= $tag-&gt;getIn('table');
        $body = $tbl[1]-&gt;getIn('body');
        $a = $body[0]-&gt;getIn('a');
        $img = $body[0]-&gt;getIn('img');
        if(count($a)&gt;2){
            if($a[3]-&gt;getValue() != '0'){
                $img = '&lt;img src=&quot;'.preg_replace(&quot;/thumbnail\//&quot;,&quot;&quot;,$img[0]-&gt;getParameter(&quot;src&quot;)).'&quot; /&gt;';
                $url = $a[3]-&gt;getParameter(&quot;href&quot;).$this-&gt;variable(&quot;id&quot;);
                return array(&quot;img&quot; =&gt; $img, &quot;url&quot; =&gt; $url);
            }
        }
        return array(&quot;img&quot; =&gt; &quot;&quot;, &quot;url&quot; =&gt; &quot;&quot;);
    }

    function description()
    {
        return &quot;feedのタイトルからDMMのAV女優情報を検索して画像を取得&quot;;
    }

    function config(){
        $config = array(
            &quot;id&quot; =&gt; &quot;アフィリエイト&quot;,
        );

        return $config;
    }
}
?&gt;
</pre>
				<p>ダウンロードして解凍後、workerフォルダに放りこんでください。</p>
				<p>Conveyor上でCustomfeedAvActressと組み合わせて実行したイメージはこんな漢字です。<br />
				2008年デビューのAV女優の一覧です。</p>
				<ul class="link">
				<li><a href="http://www.planet-ape.net/conveyor_dev/publish/avtest.php">AV ACTRESS</a></li>
				</ul>
				<p>レシピはこんな感じ</p>
				<pre class="brush: php">
&lt;?php
require_once(&quot;__init__.php&quot;);
Rhaco::import(&quot;Conveyaml&quot;);
Conveyaml::execute(
&lt;&lt;&lt; __YAML__
---
plugins:
  -
    module: CustomfeedAvActress.CustomfeedAvActress
    config:
      initial:
      name:
      yomi:
      debut: 2008
  -
    module: FilterAvActressPict.FilterAvActressPict
    config:
      id: dmmpress-001
  -
    module: HtmlOut.HtmlOut
__YAML__
);

?&gt;
</pre>
				<ul class="link">
				<li><a href="http://conveyor.rhaco.org/manual/">Conveyor &#8211; Conveyorについて</a></li>
				<li><a href="http://www.rhaco.org/">rhaco.org &#8211; Meet Rhaco</a></li>
				</ul>
				<p>※ConveyorはPHPフレームワークであるRhaco上で動くwebアプリケーションです。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-ape.net/blog/archives/570/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

