question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running the example doesn't work

See original GitHub issue

Hi there,

The example found in the readme does not work when running it. Here is the output when running it. Perhaps I’m being dumb but this is the result of running node app.js

throw new Err("There is no element selected for the '<option.name>' field. Please provide a selector, list item or use nested object structure.", {
                ^

Error: There is no element selected for the 'data' field. Please provide a selector, list item or use nested object structure.
    at Error (native)
    at new Err (/Users/josh/Projects/daystext/node_modules/err/lib/index.js:57:81)
    at /Users/josh/Projects/daystext/node_modules/scrape-it/lib/index.js:128:23
    at iterateObject (/Users/josh/Projects/daystext/node_modules/iterate-object/lib/index.js:25:17)
    at handleDataObj (/Users/josh/Projects/daystext/node_modules/scrape-it/lib/index.js:122:9)
    at Function.scrapeIt.scrapeHTML (/Users/josh/Projects/daystext/node_modules/scrape-it/lib/index.js:177:12)
    at /Users/josh/Projects/daystext/node_modules/scrape-it/lib/index.js:29:27
    at /Users/josh/Projects/daystext/node_modules/cheerio-req/lib/index.js:24:9
    at opt_callback (/Users/josh/Projects/daystext/node_modules/tinyreq/lib/index.js:57:9)
    at IncomingMessage.<anonymous> (/Users/josh/Projects/daystext/node_modules/tinyreq/lib/index.js:89:13)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
powlocommented, Apr 21, 2017

I think the issue is that the syntax has changed for the {opts} parameter and the example posted here does not work.

This works:

// Fetch the articles on the page (list)
scrapeIt("http://ionicabizau.net", {
    articles : {
        listItem: ".article"
      , data: {
            createdAt: {
                selector: ".date"
              , convert: x => new Date(x)
            }
          , title: "a.article-title"
          , tags: {
                selector: ".tags"
              , convert: x => x.split("|").map(c => c.trim()).slice(1)
            }
          , content: {
                selector: ".article-content"
              , how: "html"
            }
        }
    }
}, (err, page) => {
    console.log(err || page);
});

This does not work (taken from blog post):

// Fetch the articles on the page (list)
scrapeIt("http://ionicabizau.net", {
    listItem: ".article"
  , name: "articles"
  , data: {
        createdAt: {
            selector: ".date"
          , convert: x => new Date(x)
        }
      , title: "a.article-title"
      , tags: {
            selector: ".tags"
          , convert: x => x.split("|").map(c => c.trim()).slice(1)
        }
      , content: {
            selector: ".article-content"
          , how: "html"
        }
    }
}, (err, page) => {
    console.log(err || page);
});

Note, the change in structure for {opts}; each key is now the “name” of the scraped list.

0reactions
IonicaBizaucommented, Oct 26, 2017

@powlo Phew! 🙈 Good point! Updated the example in that post too!

Read more comments on GitHub >

github_iconTop Results From Across the Web

testing - Go example won't run - Stack Overflow
Save this question. Show activity on this post. I'm trying to add an example to a package, and run the example via go...
Read more >
Colab example doesn't run successfuly · Issue #263 - GitHub
Hello, I am trying to run the jupyter notebook example "introduction.ipynb" on "codelabs" folder using Google Colab.
Read more >
Common Build Problems - Travis CI Docs
travis_wait works by starting a process, sending it to the background, and watching the background process. If the command you pass to travis_wait...
Read more >
Unexplained Windows or software behavior may be caused ...
Describes behavior that may occur if your computer has deceptive software that is installed and running, and describes steps that you can take...
Read more >
Choose when to run jobs - GitLab Docs
The following example runs the job as a when: on_success job in merge request pipelines and scheduled pipelines. It does not run in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found