JSON ParseError意外标记

时间:2016-08-18 11:26:35

标签: ruby-on-rails json curl httparty

我正在尝试在大循环中使用API​​。代码非常简单

    Video.find_each(:batch_size => 50) do |video|

        # video_details = HTTParty.get("http://www.domain.com/webmasters/video_by_id?id=#{video.video_id}&thumbsize=medium")
        video_details = Curl::Easy.perform("http://www.domain.com/webmasters/video_by_id?id=#{video.video_id}&thumbsize=medium")

        video_data = video_details.body_str

        video_details = JSON.parse( video_data )

        # video.publish_date = video_details['publish_date']



        # video.save
    end

它适用于前16次迭代,但它会抛出此错误

JSON::ParserError 784: unexpected token at '<html><head><script type="text/javascript">

知道为什么会在第16次电话会议之后发生?

0 个答案:

没有答案