I'm trying to scrape a webpage using splashr, and I think that I need to reset my splashr container every time I run the function to scrape each link.
My issue is that, to do this, I run start_splash() and stop_splash() within the function, so that I should have a new container every time I run the function. However, this always fails, as I think my container isn't getting reset for some reason. I know this because I'll run splash_active() after I run the function, and it'll return TRUE, meaning that I still have an active container.
Do you think this is an issue with splashr? If not, could you point to the place in your code where you think tidyverse stuff is going awry? (Knowing zero about splashr, I'm having trouble identifying the location of the problem).
Also, it looks like you filed an issue in the splashr repo:
but you might have better luck getting help from Bob (the maintainer), if you include a more built-out example (such as the one here).
Lastly (again, knowing little of splashr) I'm not sure how similar your two questions are:
However, either way, you might consider posting on StackOverflow if you don't get an answer here. This is still a relatively small community, so it might be a good idea to widen your audience, especially since you're dealing with a specific framework. If you do post on SO, please link back to your question here with the answer etc. so there's no inadvertent duplication of effort!
Thanks for the response, Mara. Honestly ... I don't know. At first, I thought this was an issue with splashr, but then I thought I fixed it, and then I got HTTP 504 errors. And then I thought I fixed that, and then I thought I just got general R errors. So I really don't know what's going on
Yeah, I've been trying to contact Bob. We'll see how that goes. Thanks!
oh these are great ideas. Thanks! I'll let you know how they work. Right now, I think my biggest issue is HTTP 504 Bad Gateway Errors. So I'm trying to work through those first. I think the splashr issues are stemming from that
So I got this to work. I'm not sure what exactly did it, but here are a few things that I'm doing now that may or may not be contributing to its success. I figured I'd write this here in case anybody has similar problems in the future.
Huge sleep times.
I'm talking ~30 seconds of Sys.sleep() per scrape. This makes the whole process take forever, but I've gotten way fewer errors in general while doing this.
Usingon.exit(stop_splash(sp))
From @nwerth's suggestion, I implemented this, and it seems to work, so I've been sticking with it.
Using the long-form splashr structure rather than just render_html()
So, instead of what I did above, I now use this code below. Honestly, I don't know if this is doing anything, but it works, so I'm sticking with it.