Giter Site home page Giter Site logo

Comments (7)

ruimgoncalves avatar ruimgoncalves commented on June 17, 2024

Here is some sample code demonstrating the problem
Toggle experiment value to see different results
In my case I cant get the results in parallel from the 2 sites, the problem gets worst if you use post requests.
Is there any workaround for this?
Thanks

experiment = true

setTimeout ()->
  osm = require("osmosis")
  osm
    .get 'www.npmjs.com/search?q=scraper'
    .set
      query : 'input#site-search@value'
      packages : [
          osm.find 'ul.search-results li'
            .set
              name : '.package-details h3 a.name'
              description : '.package-details p.description'
      ]
    .data (listing)->
      console.log listing
    .error (info)->
      console.error "erro npmjs", info
, if experiment then 10 else 0

setTimeout ()->
  osm = require("osmosis")
  osm
    .get 'www.craigslist.org/about/sites'
    .set
      'location' : ['h1 + div a']
    .data (listing)->
      console.log listing.location.length
    .error (info)->
      console.error "erro craigslist", info
, if experiment then 0 else 10

from node-osmosis.

cezary avatar cezary commented on June 17, 2024

Pretty sure I'm running into this same problem; parsing multiple sites concurrently with osmosis, only the last calls done.

from node-osmosis.

andineck avatar andineck commented on June 17, 2024

I'm experiencing the same problem, but have no Idea how to fix it... Anyone?

from node-osmosis.

rchipka avatar rchipka commented on June 17, 2024

@cezary this is a known behavior of Osmosis. Osmosis only keeps a global stack count, so only the last instance will call done. There's no bulletproof way of implementing per-instance stack counting because there are many scenarios where a "done" instance can start back up again. The only way to really know is when the actual Document objects are being garbage collected. I've been adding features to libxmljs that will allow osmosis to have much more functionality. One of my next libxmljs pull requests will probably be a callback function for the Document destructor. This will allow for accurate per-instance stack counting and done calling.

from node-osmosis.

rchipka avatar rchipka commented on June 17, 2024

I'll be looking into this issue as soon as I can.

from node-osmosis.

andineck avatar andineck commented on June 17, 2024

@rc0x03 👍 thank you!

from node-osmosis.

rchipka avatar rchipka commented on June 17, 2024

This should be fixed in the latest version of Osmosis

from node-osmosis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.