Coder Social home page Coder Social logo

Comments (14)

jshemas avatar jshemas commented on June 22, 2024 9

This is awesome! Thanks for making this repo. I think i'm going to make a new module called openGraphScraperLite that will use ky for it's requests. Hopefully that will fix this problem. (This might take me a few days/weeks)

ky docs: https://github.com/sindresorhus/ky

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024 3

Okay. I made a new lib here -> https://github.com/jshemas/openGraphScraperLite and forked the example vue project here -> https://github.com/jshemas/vue-opengraph

I keep getting a bunch of CORS errors, but I think I'm getting really close to getting this to work.

from opengraphscraper.

runemy avatar runemy commented on June 22, 2024 1

Hi @jshemas Yes, here is a code repo with this problem: https://github.com/runemy/vue-opengraph

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024

Hello,

Using your code from above I was able to get this result (without using yarn add http2, using node v12.16.3):

results: {
  charset: 'iso-8859-1',
  requestUrl: 'https://www.test.com',
  success: true
}

Are you sure this error is coming from ogs? Can you post the full stack trace? What version of node are you on? What is your OS?

Is this a React app? I wonder if you are having the same issue as grpc/grpc-node#610 or googleapis/nodejs-dialogflow#314

from opengraphscraper.

NoCtrlZ1110 avatar NoCtrlZ1110 commented on June 22, 2024

The same issue!
It works perfectly on my Nodejs backend.
But on my React client (init by using create-react-app) it say
Module not found: Can't resolve 'http2'
After installed http2 (with warning "WARN deprecated [email protected]: Use the built-in module in node 9.0.0 or newer, instead"),
the client says error
TypeError: Cannot read property 'split' of undefined

(anonymous function) C:/..../node_modules/@szmarczak/http-timer/dist/source/index.js:4

1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | const defer_to_connect_1 = require("defer-to-connect");
4 | const nodejsMajorVersion = Number(process.versions.node.split('.')[0]); <----
5 | const timer = (request) => {
6 | const timings = {
7 | start: Date.now(),

Sorry my bad English.
Hope this issue would be resolved soon!
Thanks 🥰

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024

@trwong @NoCtrlZ1110 Can one of you make a code repo with this problem? I'm not familiar with react and having a code repo with this problem would help me solve it.

from opengraphscraper.

runemy avatar runemy commented on June 22, 2024

Trying to use this in a Vue App i get this error:

` ERROR Failed to compile with 4 errors 7:18:00 PM

These dependencies were not found:

  • dns in ./node_modules/cacheable-lookup/source/index.js
  • http2 in ./node_modules/http2-wrapper/source/index.js, ./node_modules/http2-wrapper/source/client-request.js and 1 other`

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024

@runemy Can you make a code repo with this problem? I'm not familiar with vue and having a code repo with this problem would help me solve it.

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024

Actually this might be the problem sindresorhus/got#1400

Got is meant for Node.js. While it can work in the browser with the right polyfills, you're on your own support-wise. Try asking on Stack Overflow instead.

openGraphScraper uses Got for making HTTP requests. I'm not really sure how to fix this with having to rewrite a lot of stuff. I could make a fork of openGraphScraper without a request library.

from opengraphscraper.

haor3 avatar haor3 commented on June 22, 2024

hello, is there any solutions for this issue?

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024

Still working on this issue. I got ky to sorta work inside openGraphScraper but there is still a few edge cases I'm working on.

from opengraphscraper.

runemy avatar runemy commented on June 22, 2024

Hi,

Sounds good with this progress :) Good work.
I do also get these CORS errors.

image

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024

So, I'm starting to think this isn't really possible to do these types of requests in the browser. This article has a good explanation.

To understand how XMLHttpRequest would be dangerous if cross-origin requests were allowed, imagine if you visited a site at evil.com that used XMLHttpRequest to make requests to gmail.com. If you were logged into Gmail in your browser, evil.com would be able to read all of your email. This example shows why it is the site that receives the request that must indicate when cross-origin XMLHttpRequest is allowed. If the requesting site could bypass the browser's restriction, malicious websites could access any site you were logged into.

from opengraphscraper.

jshemas avatar jshemas commented on June 22, 2024

Closing this for now. I think the best fix for this problem is to use a backend server to make the requests and then pass in the html into ogs.

from opengraphscraper.

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.