0
所以我想我刮項目傳遞給PHP腳本,我有我的管道:通刮項目作爲JSON PHP腳本
class TalkPhpPipeline(object):
def process_item(self, item, spider):
toPHP = json.dumps(dict(item))
os.system('/usr/bin/php script.php %s' % toPHP)
return item
,並在我的script.php
<? require_once('wp-config.php');
$string = $argv[1];
echo 'PHP see this ';
var_dump($string);
蜘蛛與script.php對話很好,但是我的script.php只能看到像這樣的{title:
,如果我用item['title']
替換爲PHP,那麼PHP端會看到[usomewhere only we know]
,我真的想傳遞給php是一個字符串,如: {'title': [u'somewhere only we know']}
或只是{'title': ['somewhere only we know']}
,當然,我的項目包含的所有其他字段,我該怎麼做?
謝謝,