Code Monkey home page Code Monkey logo

Comments (3)

JimmyLaurent avatar JimmyLaurent commented on August 15, 2024

No it's not possible.

In the browser you can't do cross domain requests unless CORS is enabled on the website you want to query.

You can still expose the library through a rest api but you'll need a backend.

from torrent-search-api.

atuaimi avatar atuaimi commented on August 15, 2024

Assuming CORS can be solved somehow (CORS proxy for example). Do you think the module can easily be modified to run on browser? It seems that the only problem is superagent.agent that is used by the x-ray-crawler and only exists in the node environment.

from torrent-search-api.

JimmyLaurent avatar JimmyLaurent commented on August 15, 2024

If the only problem is the superagent.agent in x-ray-crawler , you only have to replace this dependency with something else like fetch, axios or another library.

Hint: try to look into X-ray pluggable drivers, maybe you can make a custom driver that run in browsers.

You have to modify the Xray signature:

In xray
Replace:

function Xray (options) {
  var crawler = Crawler()

With :

function Xray (options, driver) {
  var crawler = Crawler(driver)

In torrent-provider

Replace:

      this.__x = Xray({ filters: filters });
      this.__x.driver(driver({
        method: 'GET',
        jar: this.cookieJar,
        headers: this.headers
      }))

With:

      this.__x = Xray({ filters: filters }, driver({
        method: 'GET',
        jar: this.cookieJar,
        headers: this.headers
      }));

Then you have to adapt the driver x-ray-request driver to use browser-request instead of request

I think this should work.

from torrent-search-api.

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.