Coder Social home page Coder Social logo

how to remap url about telescopy HOT 4 CLOSED

FerX avatar FerX commented on August 10, 2024
how to remap url

from telescopy.

Comments (4)

Ineluki avatar Ineluki commented on August 10, 2024 1

Haven't thought about that yet, but it should work with the htmlAttributeFilter hooks. So if you're looking at normal links you'd need to override the 'a.href'. It should look something like this:

new Telescopy({
 	htmlAttributeFilters: {
    	'a.href': {
			tag: 'a',
			filter: a => a.href && a.href.length,
			exec: (attributes,args,resource) => {
				let url = attributes.href;
				//parse url, remove random parameter and reformat here
				//mark as link to be processed
				attributes.href = resource.processResourceLink( url, "text/html" );
			}
		}
	}
})

The only other place where every url that will be processed runs through is Resource.prototype.processResourceLink but there's no easy way to hook into it unless you override the prototype. Hope that helps!

from telescopy.

FerX avatar FerX commented on August 10, 2024

thanks for the advice but I still have 2 problems:
1- some links are images, if I leave "text / html" do not download them, unfortunately they are links without extension so I do not know if png or jpg.
2 - in addition to downloading part of the main site is downloading me all google, is not limited to the domain indicated?

thanks.

from telescopy.

Ineluki avatar Ineluki commented on August 10, 2024
  1. for the images you can do the same as described above, but for the key 'img.src'. I might add a better hook in the next version. if they do not have an extension, my experience has shown that you can still save them all as .jpg and the browser will correct for it when viewing the mirrored website. otherwise you need some logic to determine what they are before the download begins. that is the only way.

  2. if you filters are not working I advice you read the documentation and use the test-tool for a specific url:
    telescopy-test-rules config.js http://example.com/some-specific-url
    it will list all found urls and if they were allowed by your url filter settings

from telescopy.

FerX avatar FerX commented on August 10, 2024

thanks for your help.

from telescopy.

Related Issues (2)

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.