【问题标题】:Node.js - Craigslist bulk post api (Failed to parse rss)Node.js - Craigslist 批量发布 api(无法解析 rss)
【发布时间】:2015-10-09 00:43:44
【问题描述】:

我正在使用 craigslist 的批量发布 API。我写了一个看起来像这样的快速脚本:

var https = require('https');
var posting = '<?xml version="1.0"?><rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cl="http://www.craigslist.org/about/cl-bulk-ns/1.0"><channel><items><rdf:li rdf:resource="NYCBrokerHousingSample1"/><rdf:li rdf:resource="NYCBrokerHousingSample2"/></items><cl:auth username="example@example.com" password="example" accountID="14"/></channel><item rdf:about="NYCBrokerHousingSample1"><cl:category>fee</cl:category><cl:area>nyc</cl:area><cl:subarea>mnh</cl:subarea><cl:neighborhood>Upper West Side</cl:neighborhood><cl:housingInfo price="1450" bedrooms="0" sqft="600"/><cl:replyEmail privacy="C">bulkuser@bulkposterz.net</cl:replyEmail><cl:brokerInfo companyName="Joe Sample and Associates" feeDisclosure="fee disclosure here" /><title>Spacious Sunny Studio in Upper West Side</title><description><![CDATA[posting body here]]></description></item><item rdf:about="NYCBrokerHousingSample2"><cl:category>fee</cl:category><cl:area>nyc</cl:area><cl:subarea>mnh</cl:subarea><cl:neighborhood>Chelsea</cl:neighborhood><cl:housingInfo price="2175" bedrooms="1" sqft="850" catsOK="1"/><cl:mapLocation city="New York" state="NY" crossStreet1="23rd Street" crossStreet2="9th Avenue" latitude="40.746492" longitude="-74.001326"/><cl:replyEmail privacy="C" otherContactInfo="212.555.1212">bulkuser@bulkposterz.net</cl:replyEmail><cl:brokerInfo companyName="Joe Sample and Associates" feeDisclosure="fee disclosure here" /><title>1BR Charmer in Chelsea</title><description><![CDATA[posting body goes here]]></description><cl:PONumber>Purchase Order 094122</cl:PONumber></item></rdf:RDF>'

var options = {
  hostname: 'post.craigslist.org',
  path: '/bulk-rss/validate',
  method: 'POST',
  headers: {
    'Content-Type' : 'application/x-www-form-urlencoded'
  }
};

var req = https.request(options, function(res) {
  console.log("headers: ", res);

  res.on('data', function(d) {
    process.stdout.write(d);
  });
});
req.write(posting)
req.end()

req.on('error', function(e) {
  console.error(e);
});

我收到 415 Unsupported Media Type 响应以及附加消息 no element found at line 1, column 0, byte -1。 xml 直接取自他们的示例,因此解析 xml 似乎应该没有问题,除非我发送 https 请求的方式有问题。

【问题讨论】:

    标签: xml node.js api rss craigslist


    【解决方案1】:

    要通过 Craigslist 批量发帖 API 发帖,您必须有一个付费帐户,通过电话等方式对您进行验证,并且每次发帖都需要付费。这可能是它不起作用的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      相关资源
      最近更新 更多