Ruby on Rails Monday, December 31, 2018



On Monday, December 31, 2018 at 7:25:13 AM UTC-5, Colin Law wrote:
On Mon, 31 Dec 2018 at 12:12, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>> >
>> >
>> >
>> > On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>> >>
>> >> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> >> > ...
>> >> > 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
>
>
> Now I only get connection reset by peer when I try to make the request

Can't help you there, presumably either the website has changed or you
have changed the way you are fetching it.  Try the url in a browser.

Colin

 I changed my code and now getting a text/html content type response Not sure what I'm doing I commented out my previous creation of http object and used an inline syntax that's part of the creation of res object

require "net/http"
require "uri"
url = URI.parse("https://www.ali<notshown>.com/item/Robotic-Vacuum-Cleaner-Proscenic-790T-Vacuum-Mop-Sweep-3-in-1-Cleaner-for-Pet-Hair-Wifi/32840149410.html?spm=2114.search0104.3.1.24d566b6GAD2uI&ws_ab_test=searchweb0_0,searchweb201602_1_10065_10068_10130_10890_10547_319_10546_317_10548_5730311_10545_10696_453_10084_454_10083_5729211_10618_10307_538_537_536_10059_10884_10887_100031_321_322_10103-10890,searchweb201603_51,ppcSwitch_0&algo_expid=99dc32b9-d1ce-4020-8bec-624c18225f44-0&algo_pvid=99dc32b9-d1ce-4020-8bec-624c18225f44")
#http = Net::HTTP.new(url.host, url.port)
#http.use_ssl = true
req = Net::HTTP::Get.new url 
res = Net::HTTP.start(url.host, url.port, :use_ssl => url.scheme == 'https') {|http| http.request req}
puts res.body

--
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/638bfc50-c217-4a52-892e-a3302b537f47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Monday, December 31, 2018 at 7:25:13 AM UTC-5, Colin Law wrote:
On Mon, 31 Dec 2018 at 12:12, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>> >
>> >
>> >
>> > On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>> >>
>> >> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> >> > ...
>> >> > 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
>
>
> Now I only get connection reset by peer when I try to make the request

Can't help you there, presumably either the website has changed or you
have changed the way you are fetching it.  Try the url in a browser.

Colin

I changed my code and now getting a text/html content type response Not sure what I'm doing I commented out my previous creation of http object and used an inline syntax that's part of the creation of res object

require "net/http"
require "uri"
url = URI.parse("https://www.aliexpress.com/item/Robotic-Vacuum-Cleaner-Proscenic-790T-Vacuum-Mop-Sweep-3-in-1-Cleaner-for-Pet-Hair-Wifi/32840149410.html?spm=2114.search0104.3.1.24d566b6GAD2uI&ws_ab_test=searchweb0_0,searchweb201602_1_10065_10068_10130_10890_10547_319_10546_317_10548_5730311_10545_10696_453_10084_454_10083_5729211_10618_10307_538_537_536_10059_10884_10887_100031_321_322_10103-10890,searchweb201603_51,ppcSwitch_0&algo_expid=99dc32b9-d1ce-4020-8bec-624c18225f44-0&algo_pvid=99dc32b9-d1ce-4020-8bec-624c18225f44")
#http = Net::HTTP.new(url.host, url.port)
#http.use_ssl = true
req = Net::HTTP::Get.new url 
res = Net::HTTP.start(url.host, url.port, :use_ssl => url.scheme == 'https') {|http| http.request req}
puts res.body

--
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/fc64810f-93a2-47ce-ba64-44a6b36ee00a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Monday, December 31, 2018 at 7:25:13 AM UTC-5, Colin Law wrote:
On Mon, 31 Dec 2018 at 12:12, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>> >
>> >
>> >
>> > On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>> >>
>> >> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> >> > ...
>> >> > 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
>
>
> Now I only get connection reset by peer when I try to make the request

Can't help you there, presumably either the website has changed or you
have changed the way you are fetching it.  Try the url in a browser.

Colin

Yes the requests still work in a browser Maybe I just need to kill  Net::HTTP process Let me try to reboot Please stand by 

--
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/a04c0005-be15-4c75-b69f-98f906013844%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Mon, 31 Dec 2018 at 12:12, fugee ohu <fugee279@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>> >
>> >
>> >
>> > On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>> >>
>> >> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> >> > ...
>> >> > 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
>
>
> Now I only get connection reset by peer when I try to make the request

Can't help you there, presumably either the website has changed or you
have changed the way you are fetching it. Try the url in a browser.

Colin

--
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/CAL%3D0gLut4K%3D3jkLGKhnCPcq6QmNdOG2SJREVpgJwj9cjGixVLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Mon, 31 Dec 2018 at 05:26, fugee ohu <fugee279@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>> >
>> >
>> >
>> > On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>> >>
>> >> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> >> > ...
>> >> > 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?

Colin

>
> --
> 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/d5068ec8-3c81-4d4a-ba0e-70fdda4dff2e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
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/CAL%3D0gLtSfUJgBkfKskW%2BCBn4w3iVs0S8-KtCVwaZJRFE7LhZ2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> > ...
>> > 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

Now I only get connection reset by peer when I try to make the request 

--
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/bdf21207-b791-4ef0-97ea-6faae551dd8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Sunday, December 30, 2018



On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> > ...
>> > 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

--
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/d5068ec8-3c81-4d4a-ba0e-70fdda4dff2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Sunday, December 30, 2018 at 10:56:30 AM UTC-5, Colin Law wrote:
On Sun, 30 Dec 2018 at 15:45, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> > ...
>> > 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

I don't know I'm repeating what I read somewhere else about jsonp actually

--
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/6e5a6960-33bb-4309-a00a-3452ad3276e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sun, Dec 30, 2018 at 3:37 AM fugee ohu <fugee279@gmail.com> wrote:
>>
> You mean the Net::HTTP docs? I don't know I haven't thought to read them

๐Ÿ™„

> I found this page http://po-ru.com/diary/turning-jsonp-callbacks-into-a-ruby-api-with-johnson/ but don't understand it

That's an interesting approach though `johnson` is abandoned; you
could try using `therubyracer` instead.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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/CACmC4yCaFLSGx9horGE4SZDYtfu%2BSqW9Gq%2BcB%2BpfRSwVyaiGCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sun, 30 Dec 2018 at 15:45, fugee ohu <fugee279@gmail.com> wrote:
>
>
>
> On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
>>
>> On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
>> > ...
>> > 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

--
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/CAL%3D0gLsK69PUcYqY5YRx5URfjURUTeJ9eSN8sen1BzKMpX8i2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Sunday, December 30, 2018 at 8:36:40 AM UTC-5, Colin Law wrote:
On Sun, 30 Dec 2018 at 12:06, fugee ohu <fuge...@gmail.com> wrote:
> ...
> 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 

--
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/2be0e8dc-cc9a-4a57-b082-a08c18edfa25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sun, 30 Dec 2018 at 12:06, fugee ohu <fugee279@gmail.com> wrote:
> ...
> 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

--
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/CAL%3D0gLs5amxf-YeV9gZu5-YxZyXzKFyhjRvmePUCxiCoqa567A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, December 29, 2018 at 10:02:07 AM UTC-5, Walter Lee Davis wrote:

> On Dec 29, 2018, at 7:13 AM, fugee ohu <fuge...@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
 

It's not json it's javascript so I don't have to run JSON.parse 

--
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/9e3f36fb-644f-4efb-8007-bc6131244e44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, December 28, 2018 at 3:37:12 PM UTC-5, Hassan Schroeder wrote:
On Thu, Dec 27, 2018 at 11:29 PM fugee ohu <fuge...@gmail.com> wrote:

>> On Thu, Dec 27, 2018 at 4:10 PM fugee ohu <fuge...@gmail.com> wrote:

> What docs? You asked if I passed in an `accept request header` so I asked if I need to You're obscuring this thread

>> > So I need to pass in accept request header json as the first parameter to NET::HTTP ?

You asked the question above ^^ and without looking at the docs
I wouldn't know the order of arguments ("parameters") to that library.

And I didn't say you *needed* to do anything, I just asked if you were
specifying the content-type you wanted in the request. There's still no
guarantee that's what you'll get, but there's a better chance ๐Ÿ˜€

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Oh ok sorry You mean the Net::HTTP docs? I don't know I haven't thought to read them I found this page http://po-ru.com/diary/turning-jsonp-callbacks-into-a-ruby-api-with-johnson/ but don't understand it

--
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/fadafac3-d8ae-4a9c-8326-0621b11e220e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, December 29, 2018 at 10:02:07 AM UTC-5, Walter Lee Davis wrote:

> On Dec 29, 2018, at 7:13 AM, fugee ohu <fuge...@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


All my requests are drawing  'Errno::ECONNRESET: Connection reset by peer' now I don't know why

--
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/69ec1640-6e8a-41db-9787-f1828412be8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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.

Ruby on Rails



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  

--
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/3a6db669-4c95-4457-9d68-a5ff78e11da1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sat, 29 Dec 2018 at 11:16, fugee ohu <fugee279@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

--
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/CAL%3D0gLt79O7WfNPBhwive-gS0tyvQPV6uir4XHqGQwZwC2gJOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, December 29, 2018 at 5:48:31 AM UTC-5, Colin Law wrote:
On Sat, 29 Dec 2018 at 10:36, fugee ohu <fuge...@gmail.com> wrote:
>
> json_data = res.body.gsub(/^.+{/, "{").chomp(");")
> json = JSON.parse(json_data)
> JSON::ParserError: 765: unexpected token at '{\"pvid\":\"ff43f2dc-3f86-42a3-bfa8-49c117e9da6a\",\"scm-cnt\":\"1007.13482.95643.0\",

Why have you posted this?  You still have \" instead of "
As I said, look again at the spec of what a JSON string should look
like.  Until you have that there is no point feeding into parse()

Colin

 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

--
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/2d084e6e-dcb5-4cd7-a571-8873434d3f0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, December 29, 2018 at 5:48:31 AM UTC-5, Colin Law wrote:
On Sat, 29 Dec 2018 at 10:36, fugee ohu <fuge...@gmail.com> wrote:
>
> json_data = res.body.gsub(/^.+{/, "{").chomp(");")
> json = JSON.parse(json_data)
> JSON::ParserError: 765: unexpected token at '{\"pvid\":\"ff43f2dc-3f86-42a3-bfa8-49c117e9da6a\",\"scm-cnt\":\"1007.13482.95643.0\",

Why have you posted this?  You still have \" instead of "
As I said, look again at the spec of what a JSON string should look
like.  Until you have that there is no point feeding into parse()

Colin

Well it seems my response shouldn't contain the \" characters if it's json so It's not json it's js? because i already read that the string response is  jsonp which actually contains js, not json

--
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/6d889ac9-86b1-4dc9-b1aa-68a91e87c5b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sat, 29 Dec 2018 at 10:36, fugee ohu <fugee279@gmail.com> wrote:
>
> json_data = res.body.gsub(/^.+{/, "{").chomp(");")
> json = JSON.parse(json_data)
> JSON::ParserError: 765: unexpected token at '{\"pvid\":\"ff43f2dc-3f86-42a3-bfa8-49c117e9da6a\",\"scm-cnt\":\"1007.13482.95643.0\",

Why have you posted this? You still have \" instead of "
As I said, look again at the spec of what a JSON string should look
like. Until you have that there is no point feeding into parse()

Colin

--
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/CAL%3D0gLtiWkvvfSRf42bdJrMri0sTFGojc2teuT2GSAt_f6oQsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, December 29, 2018 at 5:01:03 AM UTC-5, Colin Law wrote:
On Sat, 29 Dec 2018 at 09:37, fugee ohu <fuge...@gmail.com> wrote:
> ..
>>> JSON::ParserError: 765: unexpected token at '({"success":true,"code":0,"results":[{"productId":32817
>>
> ...
> JSON::ParserError: 765: unexpected token at '{\"pvid\":\"805ba4ee-6446-4148-ab0a-ff5e51c0ab24\",\"

You have not only taken out the bracket, but you have also changed all
the " to \".  Did you not notice that yourself?

Colin


json_data = res.body.gsub(/^.+{/, "{").chomp(");")
json = JSON.parse(json_data)
JSON::ParserError: 765: unexpected token at '{\"pvid\":\"ff43f2dc-3f86-42a3-bfa8-49c117e9da6a\",\"scm-cnt\":\"1007.13482.95643.0\", ...
 

--
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/cad0f102-e512-43cb-b3f1-c75a800748bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, December 29, 2018 at 5:01:03 AM UTC-5, Colin Law wrote:
On Sat, 29 Dec 2018 at 09:37, fugee ohu <fuge...@gmail.com> wrote:
> ..
>>> JSON::ParserError: 765: unexpected token at '({"success":true,"code":0,"results":[{"productId":32817
>>
> ... 
> JSON::ParserError: 765: unexpected token at '{\"pvid\":\"805ba4ee-6446-4148-ab0a-ff5e51c0ab24\",\"

You have not only taken out the bracket, but you have also changed all
the " to \".  Did you not notice that yourself?

Colin

No I didn't notice, thanks

--
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/7607288f-fac5-4b8f-986c-c41a738b3009%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sat, 29 Dec 2018 at 09:37, fugee ohu <fugee279@gmail.com> wrote:
> ..
>>> JSON::ParserError: 765: unexpected token at '({"success":true,"code":0,"results":[{"productId":32817
>>
> ...
> JSON::ParserError: 765: unexpected token at '{\"pvid\":\"805ba4ee-6446-4148-ab0a-ff5e51c0ab24\",\"

You have not only taken out the bracket, but you have also changed all
the " to \". Did you not notice that yourself?

Colin

--
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/CAL%3D0gLvpcZ%2BatfM%2BkxbV8Sx02FPJWu9hQiVMN4aOokM-aR1HvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Saturday, December 29, 2018 at 2:12:33 AM UTC-5, Colin Law wrote:


On Sat, 29 Dec 2018, 03:42 fugee ohu <fuge...@gmail.com wrote:


On Friday, December 28, 2018 at 5:00:46 PM UTC-5, Colin Law wrote:
On Fri, 28 Dec 2018 at 21:40, fugee ohu <fuge...@gmail.com> wrote:
> ...
> I think I just need to strip the leading /**/jQuery18307882633047005491_1545805999753 from the result  /**/jQuery18307882633047005491_1545805999753({"success":true,"code":0,"results":[{"productId":32817749905,
> Anyone can help with the regex?

If you can't work out the regex just find the position of the first {
and strip to there.

Colin

I gsub'd for the first  ({

 json_data = res.body.gsub(/^.+\(\{/, "\(\{")
json = JSON.parse(json_data)
JSON::ParserError: 765: unexpected token at '({"success":true,"code":0,"results":[{"productId":32817


Look at the JSON spec again. What should the first char be?

Colin

--
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-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/007843ea-8793-46fb-ab40-bf63e55fb2bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

The first character should be a curly bracket 
json_data = res.body.gsub(/^.+\{/, "\{").chop
json = JSON.parse(json_data)

JSON::ParserError: 765: unexpected token at '{\"pvid\":\"805ba4ee-6446-4148-ab0a-ff5e51c0ab24\",\"

--
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/74861111-d6f7-4752-b20c-ffc335da704d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Friday, December 28, 2018



On Sat, 29 Dec 2018, 03:42 fugee ohu <fugee279@gmail.com wrote:


On Friday, December 28, 2018 at 5:00:46 PM UTC-5, Colin Law wrote:
On Fri, 28 Dec 2018 at 21:40, fugee ohu <fuge...@gmail.com> wrote:
> ...
> I think I just need to strip the leading /**/jQuery18307882633047005491_1545805999753 from the result  /**/jQuery18307882633047005491_1545805999753({"success":true,"code":0,"results":[{"productId":32817749905,
> Anyone can help with the regex?

If you can't work out the regex just find the position of the first {
and strip to there.

Colin

I gsub'd for the first  ({

 json_data = res.body.gsub(/^.+\(\{/, "\(\{")
json = JSON.parse(json_data)
JSON::ParserError: 765: unexpected token at '({"success":true,"code":0,"results":[{"productId":32817


Look at the JSON spec again. What should the first char be?

Colin

--
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/007843ea-8793-46fb-ab40-bf63e55fb2bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAL%3D0gLvz6K0_DXCwGBfupqKsVLeZH3P81KuYJTyBDM9BZjXH3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, December 28, 2018 at 5:00:46 PM UTC-5, Colin Law wrote:
On Fri, 28 Dec 2018 at 21:40, fugee ohu <fuge...@gmail.com> wrote:
> ...
> I think I just need to strip the leading /**/jQuery18307882633047005491_1545805999753 from the result  /**/jQuery18307882633047005491_1545805999753({"success":true,"code":0,"results":[{"productId":32817749905,
> Anyone can help with the regex?

If you can't work out the regex just find the position of the first {
and strip to there.

Colin

I gsub'd for the first  ({

 json_data = res.body.gsub(/^.+\(\{/, "\(\{")
json = JSON.parse(json_data)
JSON::ParserError: 765: unexpected token at '({"success":true,"code":0,"results":[{"productId":32817

--
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/007843ea-8793-46fb-ab40-bf63e55fb2bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Fri, 28 Dec 2018 at 21:40, fugee ohu <fugee279@gmail.com> wrote:
> ...
> I think I just need to strip the leading /**/jQuery18307882633047005491_1545805999753 from the result /**/jQuery18307882633047005491_1545805999753({"success":true,"code":0,"results":[{"productId":32817749905,
> Anyone can help with the regex?

If you can't work out the regex just find the position of the first {
and strip to there.

Colin

--
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/CAL%3D0gLsi4jY7g5Md1BGEnCNFO6nEW4mM-XUhX4WU_7%2B8MD0Mwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Wednesday, November 7, 2018 at 10:35:01 AM UTC-5, fugee ohu wrote:
I'm not very good with the consoles in chrome and firefox but I couldn't find the text I was looking for in source even though it's displayed as text seemingly, the cursur changes to a vertical line on mouse-over I found this html below in the source How does this html create the text that displays?

   <div class="ui-box product-description-main" id="j-product-description">          <div class="ui-box-title">Product Description</div>          <div class="ui-box-body">                <div class="description-content" data-role="description" data-spm="1000023">              <div class="loading32"></div>              </div>            </div>      </div>

I think I just need to strip the leading /**/jQuery18307882633047005491_1545805999753 from the result  /**/jQuery18307882633047005491_1545805999753({"success":true,"code":0,"results":[{"productId":32817749905,
Anyone can help with the regex?

--
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/97351743-3274-4580-9ad6-0f67602cd0cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, December 28, 2018 at 11:04:37 AM UTC-5, Colin Law wrote:
On Fri, 28 Dec 2018 at 15:53, fugee ohu <fuge...@gmail.com> wrote:
>  ...
> I don't know what a valid json response is supposed to look like Also I don't know if it makes a difference they're using Struts framework

Once again I have googled for a link for you
https://www.w3schools.com/whatis/whatis_json.asp

Colin

 Thanks The response I'm trying to parse is JSONP which is javascript (not json) and has some prepending like   /**/jQuery18307882644047003491_1545786199753 so I have to strip it out of the response or make my call to the script without the callback maybe?

--
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/bdab92b7-b894-4ecb-8df9-46c029b616da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, December 28, 2018 at 11:04:37 AM UTC-5, Colin Law wrote:
On Fri, 28 Dec 2018 at 15:53, fugee ohu <fuge...@gmail.com> wrote:
>  ...
> I don't know what a valid json response is supposed to look like Also I don't know if it makes a difference they're using Struts framework

Once again I have googled for a link for you
https://www.w3schools.com/whatis/whatis_json.asp

Colin

Thanks The response I'm trying to parse is JSONP which is javascript (not json) and has some prepending like   /**/jQuery18307882644047003491_1545786199753 so I have to strip it out of the response or make my call to the script without the callback maybe?

--
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/6182f069-1033-46cb-902e-bdfbac987b66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Thu, Dec 27, 2018 at 11:29 PM fugee ohu <fugee279@gmail.com> wrote:

>> On Thu, Dec 27, 2018 at 4:10 PM fugee ohu <fuge...@gmail.com> wrote:

> What docs? You asked if I passed in an `accept request header` so I asked if I need to You're obscuring this thread

>> > So I need to pass in accept request header json as the first parameter to NET::HTTP ?

You asked the question above ^^ and without looking at the docs
I wouldn't know the order of arguments ("parameters") to that library.

And I didn't say you *needed* to do anything, I just asked if you were
specifying the content-type you wanted in the request. There's still no
guarantee that's what you'll get, but there's a better chance ๐Ÿ˜€

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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/CACmC4yCC_%2BOX1_c9RyC0OCTadzQ-gTdVVJG6St71jbXgoOw6Rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Fri, 28 Dec 2018 at 15:53, fugee ohu <fugee279@gmail.com> wrote:
> ...
> I don't know what a valid json response is supposed to look like Also I don't know if it makes a difference they're using Struts framework

Once again I have googled for a link for you
https://www.w3schools.com/whatis/whatis_json.asp

Colin

--
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/CAL%3D0gLu%3Dp4%3DLkE4FEh%3D3P8h_Nr%2BfJZO0wVj%3DGppC5nWB-P73Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, December 28, 2018 at 9:38:38 AM UTC-5, Colin Law wrote:
On Fri, 28 Dec 2018 at 14:19, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Friday, December 28, 2018 at 8:38:14 AM UTC-5, Colin Law wrote:
>>
>> On Fri, 28 Dec 2018 at 12:58, fugee ohu <fuge...@gmail.com> wrote:
>> > ...
>> > Yes the sources tab showed the script and it's output, a string, but how do I parse it into an object?
>>
>> If it is a JSON string then JSON.parse should do it.  If it is not
>> then perhaps you need to strip something off to get to be valid JSON.
>> Not sure what any of this has got to do with Rails.
>>
>> Colin
>
>
> It does of course have to do with rails That's why I asked here The reason it has to do with rails is because I'm working within the rails console of my app which I'm trying to scrape data for JSON.parse returns invalid token

Dos the string look like valid json to you?

Colin

>
> --  
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/15d9c5ff-f243-4016-a4dd-a7ba43041658%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

I don't know what a valid json response is supposed to look like Also I don't know if it makes a difference they're using Struts framework

--
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/d5b1177d-0a84-4a5c-aded-c2538a0f2e56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Fri, 28 Dec 2018 at 14:19, fugee ohu <fugee279@gmail.com> wrote:
>
>
>
> On Friday, December 28, 2018 at 8:38:14 AM UTC-5, Colin Law wrote:
>>
>> On Fri, 28 Dec 2018 at 12:58, fugee ohu <fuge...@gmail.com> wrote:
>> > ...
>> > Yes the sources tab showed the script and it's output, a string, but how do I parse it into an object?
>>
>> If it is a JSON string then JSON.parse should do it. If it is not
>> then perhaps you need to strip something off to get to be valid JSON.
>> Not sure what any of this has got to do with Rails.
>>
>> Colin
>
>
> It does of course have to do with rails That's why I asked here The reason it has to do with rails is because I'm working within the rails console of my app which I'm trying to scrape data for JSON.parse returns invalid token

Dos the string look like valid json to you?

Colin

>
> --
> 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/15d9c5ff-f243-4016-a4dd-a7ba43041658%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
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/CAL%3D0gLvZG350Cs8tKmzHDmCwP6aMM8FJ%2BE-CtA38bZoBZFE4Og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Friday, December 28, 2018 at 8:38:14 AM UTC-5, Colin Law wrote:
On Fri, 28 Dec 2018 at 12:58, fugee ohu <fuge...@gmail.com> wrote:
> ...
> Yes the sources tab showed the script and it's output, a string, but how do I parse it into an object?

If it is a JSON string then JSON.parse should do it.  If it is not
then perhaps you need to strip something off to get to be valid JSON.
Not sure what any of this has got to do with Rails.

Colin

It does of course have to do with rails That's why I asked here The reason it has to do with rails is because I'm working within the rails console of my app which I'm trying to scrape data for JSON.parse returns invalid token 

--
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/15d9c5ff-f243-4016-a4dd-a7ba43041658%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Fri, 28 Dec 2018 at 12:58, fugee ohu <fugee279@gmail.com> wrote:
> ...
> Yes the sources tab showed the script and it's output, a string, but how do I parse it into an object?

If it is a JSON string then JSON.parse should do it. If it is not
then perhaps you need to strip something off to get to be valid JSON.
Not sure what any of this has got to do with Rails.

Colin

--
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/CAL%3D0gLuGzKxT7NXVWH5_MLr7tVJ%3DSfsF0DYAN0n8aKwepNbLjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Wednesday, November 7, 2018 at 12:28:05 PM UTC-5, Jake Niemiec wrote:
The ui-box class would indicate that it is a react component: https://github.com/segmentio/ui-box

React components are run client-side, meaning the text you are looking for is inserted into the document after the page runs <script> tags. I would take a look at the Sources tab in chrome, you can find all the loaded scripts there.

On Wed, Nov 7, 2018 at 10:17 AM fugee ohu <fuge...@gmail.com> wrote:


On Wednesday, November 7, 2018 at 11:01:32 AM UTC-5, Colin Law wrote:
I should think that javascript is involved.  I am sure you asked a
similar question before when you were trying to scrape a website and
couldn't find the text in the html.

Colin
On Wed, 7 Nov 2018 at 15:35, fugee ohu <fuge...@gmail.com> wrote:
>
> I'm not very good with the consoles in chrome and firefox but I couldn't find the text I was looking for in source even though it's displayed as text seemingly, the cursur changes to a vertical line on mouse-over I found this html below in the source How does this html create the text that displays?
>
>    <div class="ui-box product-description-main" id="j-product-description">
>         <div class="ui-box-title">Product Description</div>
>         <div class="ui-box-body">
>
>             <div class="description-content" data-role="description" data-spm="1000023">
>             <div class="loading32"></div>
>             </div>
>
>         </div>
>     </div>
>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.

 Yes, within that context, javascript, how does it happen that the text I'm viewing in the browser isn't visible in source?

--
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-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/12b65225-60e5-4fe3-80a7-9ebb8013f312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yes the sources tab showed the script and it's output, a string, but how do I parse it into an object? 

--
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/807c00bd-358f-4aff-b0f1-78b04f4970e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.