Why I get "ECONNRESET" when I try to get an element from a remote html page

Misha

I'm trying to recover the price of an article on GearBest. For that, I use Cheerio to do webscraping. I created a little script (I'm using NodeJS) but I still get the same error : "Error: read ECONNRESET". I have done some research but I can't solve the error.

Here's my code :

// https://www.gearbest.com/laptops/pp_786411.html')
//<span class="goodsIntro_price js-currency js-panelIntroPrice" data-currency="939.99" data-wrap="0" data-round="2">€836.60</span>
const cheerio = require('cheerio')
const port = 8080;
const express = require('express')
const app = express()
const request = require('request')

var url = 'https://www.gearbest.com/laptops/pp_786411.html'
request(url, (error, response, html) => {
    if(!error && response.statusCode == 200){
        const $ = cheerio.load(html)

        const siteHeader = $('.js-panelIntroNormalPrice')

        console.log(siteHeader.text())
    } else {
        console.log('Erreur : ' + error)
        //console.log('Http code : ' + response.statusCode)
    }
})

swogger

This error appear when your connection is interrupted.

Try curl https://www.gearbest.com/laptops/pp_786411.html if it cannot fetch the page it is a network issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why I get null when try get element by id?

Why I get error when try append element to document?

why i get this error when i try to scroll through a list to its last element?

Why I get error when I try to declare local variable?

Why I get exception when I try to use AutoMapper?

Why I get error when I try to create stored procedure?

Why do I get an error for "__CrtGetFileInformationByHandleEx " when I try to compile

Why I get an empty file when I try to sort it?

Why I get error when I try to install pyaudio?

Why I get an error when I try to upload a picture

Why I get exception when I try to fetch data from tables that has many to many relationship

Why do I get 'undefined' error when I try to read session atrribute from Controller

why i get "no attirubute error" when i try to call python function from c++

why is it when I try to create a child class from a parent class(Downcasting), I get a null object

Why do I get an error (Notice: Undefined index) when I try to echo a value from my database?

Why am I getting an error when I try to get a string from my table in a Jframe?

Why do I get an Error when I try to rename a table after FROM?

get only last page when I try to scrape daily HTML tables with selenium

I am using @PathVariable from springframework. When I try to return view page name from controller, I get 404 error

I get 'undefined' when i try to fetch data from an API but when i access it again it works. why?

Array element is null when i try to get with index

React array returns undefined when i try to get specific element of it

When I try the erase the element from the Linked List, a get a segmentation fault

When i try to get data from data for edit page it's showing me error

Why is this function return empty result when I try to get column name from a table in PostgreSQL?

Why are my cookies and signedCookies empty in req when I try to get them from port 3000?

Why do I get error when try to convert Carbon to DateTime?

Why is my .load() not working when I try to get specific div

Why does my activity crash when I try to get a number?