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

Ability to apply special reformatting filter for 'source:'.. entries - '|pretty' (or jinja2 template filters on the 'filters') #1572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dgtlmoon
Copy link
Owner

@dgtlmoon dgtlmoon commented May 16, 2023

Example - You are watching the contents of a <select> list from a source:http://foobar website

You add |pretty to your CSS or xPath filter (maybe this should not be available for xpath)

and then you add a extract filter to just extract one line, but the whole list appears as one line of text

URL | https://foobar.com/page.html
FILTER | #id-of-selectbox|pretty
EXTRACT FILTER | /.+W36.L34.*/i

then, the whole select/option list is nicely formatted and I can extract the text of that one <option> value

for example

<select aria-label="Please select a Größe" class="x-msku__select-box" id="x-msku__select-box-1001" selectboxid="1001" selectboxlabel="Größe"><option value="-1">- Select -</option><option disabled="disabled" id="x-msku__option-box-1" value="1"> W30/L30   (Out of stock)</option>

becomes

<select aria-label="Please select a Größe" class="x-msku__select-box" id="x-msku__select-box-1001" selectboxid="1001" selectboxlabel="Größe">
 <option value="-1">
  Select 
 </option>
 <option disabled="disabled" id="x-msku__option-box-1" value="1">
  W30/L30   (Out of stock) 
 </option>
</select>   

Further -

We could use any jinja2 filter, as well as add custom filters, the filter does not have to be source: based filter

|capitalize |lower |pretty, maybe even custom ones like |regex(/../) and more fancy ones like |send(http://someservice.com)

using jinja2, they could be also chained

|int|if int > 10

@dgtlmoon
Copy link
Owner Author

pipe | is used by both CSS and xPath, need a different filter char

li[data-years|="1900"]

@dgtlmoon dgtlmoon changed the title Ability to supply a special reformatting filter for 'source:'.. entries - '|pretty' Ability to apply special reformatting filter for 'source:'.. entries - '|pretty' (or jinja2 template filters on the 'filters') May 16, 2023
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

Successfully merging this pull request may close these issues.

None yet

1 participant