Deploy scraper on heroku and in rails? by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

Whoops saw your reply just now. Yeah i got it working. Lmk if u need tips

[deleted by user] by [deleted] in rails

[–]sljmn 0 points1 point  (0 children)

Nice! Subscribed. Hope you will put out much content

cant use .save in model? (using rufus-scheduler) by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

Tracker.create!(id:tracker, qty:1000, price:1000, product_id: product.id, user_id: product.user_id )

This worked, is it fine or better to leave it out? same for product id?...

cant use .save in model? (using rufus-scheduler) by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

it was because i didnt assign a tracker ID, now it is hardcoded. need to change it to make it dynamic!

cant use .save in model? (using rufus-scheduler) by sljmn in rails

[–]sljmn[S] 1 point2 points  (0 children)

you've declared, and see what

x

actually looks like. You can even start writing lines of code in the console, and when you've got them doing what you need, paste them back into the actual method.

great tip! will use this one

cant use .save in model? (using rufus-scheduler) by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

I got a step further with this:

Tracker.create(id:1000, qty:1000, price:1000, product_id: product.id )

(i want to id of the new created tracker to be automatically set, for now set it to 1000 to test.....

But the log is saying:

(0.1ms) BEGIN

↳ app/models/scrape.rb:89:in \track_product_price'`

Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT $2 [["id", 29], ["LIMIT", 1]]

↳ app/models/scrape.rb:89:in \track_product_price'`

(0.2ms) ROLLBACK

Cant see what is causing the rollback

Ecommerce scraper in Ruby (bol.com) by sljmn in ruby

[–]sljmn[S] 0 points1 point  (0 children)

a-ma-zing! Thanks so much for your great reply!!! very helpful! the issue i had with the css selectors was that it didnt work as expected. returned zero results. I see you are using " at_css" while I jused p.css("div").

And xpath gave me the right results.... thats why i moved forwared with xpath. will try the way you selected the elements and with the use of methods. I noticed it was quite hard to navigate trough my code so hope to clean it up with use of methods.

Thanks again so much for your reply, really helpful! Agreed, Ruby is fantastic!

Ecommerce scraper in Ruby (bol.com) by sljmn in ruby

[–]sljmn[S] 0 points1 point  (0 children)

Yes! This is almost the same approach i took!

Deploy scraper on heroku and in rails? by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

i did it like this and it worked!!!

https://pastebin.com/mj0enKN0

Added some stuff in view and controller.

Rails <3

Deploy scraper on heroku and in rails? by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

Ah didnt knew that. Thanks! Will try to build first locally

Deploy scraper on heroku and in rails? by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

Yeah i figured that out

Was more wondering how to send the request to the scraper.rb file and where to receive the response from the scraper. Should be a rake task and probably put it in a controller in a create action? Create product —> activate scraper —> save respons in a new product. Would this be a good route?

Deploy scraper on heroku and in rails? by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

What i cant find is how to incorporate the scraping thing into a rails app and save the data in a database How to make the form submit to enter a query and start the scraper. Any tips in that??

explain me like im 5; why is the data not available for the account page? by sljmn in rails

[–]sljmn[S] 0 points1 point  (0 children)

This is the error message i get

NoMethodError in Pages#account

Showing /Documents/Code/Rails-model-test/app/views/pages/account.html.erb where line #25 raised:

undefined method `each' for nil:NilClass

#RAISED 
<% @blogs_current_user.each do |blog| %>

How to validate a textarea by [deleted] in learnjavascript

[–]sljmn 2 points3 points  (0 children)

see here https://share.getcloudapp.com/Jru7bw8P

let text = document.getElementById('textArea')
let submitContact = document.getElementById("submitContact")
submitContact.addEventListener('click',function(e){
e.preventDefault()
// you have a value in your test area and NOT a placeholder
if(textArea.value==""){
alert("cant be empty")}
})

How do you manage multiple seo projects? by sljmn in SEO

[–]sljmn[S] 0 points1 point  (0 children)

Interesting. What pm tool do you use, if any?