{"success":true,"code":0,"results":[{"productId":32815555905, ...
Looks like JSON to me (embedded in js admittedly). You said that the
data you want is in that string. If that is correct then all you have
to do is to extract it and parse it as JSON.
The escaped quotes further down the string, you see i left it ending in … there’s more to it i didn’t include it’s a long string when the parser reaches the first backslash it returns an error
>
>
>
>>
>> > ...
>> > It's not json it's javascript so I don't have to run JSON.parse
>>
>> {"success":true,"code":0,"results":[{"productId":32815555905, ...
>> Looks like JSON to me (embedded in js admittedly). You said that the
>> data you want is in that string. If that is correct then all you have
>> to do is to extract it and parse it as JSON.
>>
>> Colin
>
>
> It's not json it's javascript
What is it about the string
{"success":true,"code":0,"results":[{"productId":32815555905, ...
that makes it not JSON?
Colin
The escaped quotes further down the string, you see i left it ending in ... there's more to it i didn't include it's a long string when the parser reaches the first backslash it returns an error
That probably means you have dropped off the end of the json onto
something else, examine that area to see. Is all the data you need in
the bit before that?
If you get “Connection reset by peer” while scraping a website, it is very likely that your scraping attempts were detected and automatically blocked for a while. They might have also been alerted by all of these malformed requests.
Consider pacing out your requests so that it doesn’t look like you are scraping.
Are you seriously asking, after the years that you have been using
Ruby, that you don't know how to extract a particular section from a
string? Apart from anything else, since I haven't got access to the
full string (nor do I want it), I have no idea what the details
surrounding the JSON section are so can't tell you how to do it.