Ruby on Rails Saturday, December 29, 2018

> On Dec 29, 2018, at 7:13 AM, fugee ohu <fugee279@gmail.com> wrote:
>
>
>
> On Saturday, December 29, 2018 at 6:48:22 AM UTC-5, Colin Law wrote:
> On Sat, 29 Dec 2018 at 11:16, fugee ohu <fuge...@gmail.com> wrote:
> > ...
> > It's not clear to me what the response is Can the problem be that my request is the full url with callback and other query string data Should I just be calling the script without invoking the Struts framework callback but still provide the item number as query string data
>
> Earlier on you had something that looked like JSON to me, except for
> the stuff on the front, and you posted
>
> > I think I just need to strip the leading /**/jQuery18307882633047005491_1545805999753 from the result
> > /**/jQuery18307882633047005491_1545805999753({"success":true,"code":0,"results":[{"productId":32817749905,
> >
>
> Since then you have done something that is producing \" instead of ".
> I suggest you go back to whatever you had then.
>
> As an alternative you could try Hassan's advice. Whatever you do make
> sure you keep sufficient notes that you can always get back to the
> where you were when you find yourself going backwards.
>
> Colin
>
> That was from the beginning of the response A little further on in the response some quotes are escaped I don't know why
>

I would recommend that you put the text you get back from the URL in a file (just now, for testing purposes), so you can experiment with various transforms on it. When you have the raw data in a text file, you can take advantage of your editor's color-coding to see what is what in the raw string.

You're going to have to read through the data and figure out how it works, so you can understand what parts are data and what parts are the callback functions. Read about JSONP and what it is and how and why you would use it. Until you truly understand what the developers have been doing in order to construct their page, you won't know how to pare back the page-building parts and get just the raw data out of the payload.

Once you have done this, though, the very last step (parsing the data with the standard library JSON function) will be a trivial maraschino cherry on top of the sundae.

Until you actually understand the data, you cannot scrape it or parse it. So eat your vegetables first!

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/DA4396B6-0EDE-4C1A-A0EB-EA41829C533A%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment