Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom filters #1

Open
arshaw opened this issue Feb 9, 2011 · 2 comments
Open

custom filters #1

arshaw opened this issue Feb 9, 2011 · 2 comments

Comments

@arshaw
Copy link
Owner

arshaw commented Feb 9, 2011

Reported by toshiba13, Jun 23, 2009

New filter encoding? might be useful? international languages.

if f == 'utf-8':
    if issubclass(type(s), basestring):
        s = s.encode('utf8')

One could use a custom filter in a function?

Base href to add url automatically. within a filter?

What I'm trying and this time I liked.
Sorry I did not spread but my English is very bad. use google translator

Thanks

@arshaw
Copy link
Owner Author

arshaw commented Feb 9, 2011

Comment 1 by project member adamrshaw, Oct 22, 2009

yeah, this would be cool if you could pass an optional parameter to the scrape function.
a dictionary of filter names -> filter functions

thanks

ps- adding as base href to a url is already possible with the 'abs' filter (though it
might be better to rename this to be the 'url' filter; i'll think about it)

@quink
Copy link

quink commented Aug 6, 2011

Done in an ugly way in my fork:

data = ['{{ foo|adda }}', '<a>hello</a>', {'foo':'helloa'}, {'processors':{'adda':self.adda} }]
    def adda(self, string):
        return string + "a"
    def assertScrape(self, pattern, input, output, kwargs={}):
        return self.assertEqual(scrape(pattern, html=input, **kwargs), output)

Currently works on data after the html has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants