Left: | ||
Right: |
OLD | NEW |
---|---|
1 # python-abp | 1 # python-abp |
2 | 2 |
3 This repository contains a library for working with Adblock Plus filter lists | 3 This repository contains a library for working with Adblock Plus filter lists |
4 and the script that is used for building Adblock Plus filter lists from the | 4 and the script that is used for building Adblock Plus filter lists from the |
5 form in which they are authored into the format suitable for consumption by the | 5 form in which they are authored into the format suitable for consumption by the |
6 adblocking software. | 6 adblocking software. |
7 | 7 |
8 ## Installation | 8 ## Installation |
9 | 9 |
10 Prerequisites: | 10 Prerequisites: |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 If you don't know all the source names that are needed to render some list, | 79 If you don't know all the source names that are needed to render some list, |
80 just run `flrender` and it will report what it's missing: | 80 just run `flrender` and it will report what it's missing: |
81 | 81 |
82 $ flrender easylist.txt output/easylist.txt | 82 $ flrender easylist.txt output/easylist.txt |
83 Unknown source: 'easylist' when including 'easylist:easylist/easylist_gener | 83 Unknown source: 'easylist' when including 'easylist:easylist/easylist_gener |
84 al_block.txt' from 'easylist.txt' | 84 al_block.txt' from 'easylist.txt' |
85 | 85 |
86 You can clone the necessary repositories to a local directory and add `-i` | 86 You can clone the necessary repositories to a local directory and add `-i` |
87 options accordingly. | 87 options accordingly. |
88 | 88 |
89 ## Rendering diffs | |
90 | |
91 A diff allows a client running adblocking software such as Adblock Plus to updat e | |
Sebastian Noack
2018/09/24 22:21:09
"ad blocking" are two words.
rhowell
2018/09/25 01:53:44
Done.
| |
92 the filter lists incrementally, instead of downloading a new copy of a full list | |
93 during each update. This is meant to lessen the amount of resources used when up dating | |
94 filter lists (e.g. network data, memory usage, battery consumption, etc.), allow ing | |
95 clients to update their lists more frequently using less resources. | |
96 | |
97 Python-abp contains a script that produces the diff between two filterlists call ed | |
Sebastian Noack
2018/09/24 22:21:09
... between two versions of a filter list ...
rhowell
2018/09/25 01:53:44
Done.
| |
98 `fldiff`: | |
99 | |
100 $ fldiff base.txt latest.txt output.txt | |
101 | |
102 This will produce a diff that shows how a client may get from `base.txt` to | |
103 `latest.txt`, and write the output to `output.txt`. The output argument is | |
104 optional. If ommitted, the data will be written to `stdout`. | |
105 | |
106 The script produces three types of lines, as specified in the [technical specifi cation][5]: | |
Sebastian Noack
2018/09/24 22:21:09
This URL is not defined at the bottom.
rhowell
2018/09/25 01:53:45
Oops! I had it in a markdown editor, but forgot to
| |
107 * Special comments of the form `! <name>:[ <value>]` | |
108 * Added filters of the form `+ <filter-text>` | |
109 * Removed filter of the form `- <filter-text>` | |
110 | |
111 When applying the diff, a client will update any values in the form of special | |
112 comments, remove any filters that have been removed, and then add any filters | |
Sebastian Noack
2018/09/24 22:21:09
That is not accurate. As of the current specificat
rhowell
2018/09/25 01:53:45
Ah right. I missed that change to the spec. Fixed.
| |
113 that have been added. | |
114 | |
89 ## Library API | 115 ## Library API |
90 | 116 |
91 Python-abp can also be used as a library for parsing filter lists. For example | 117 Python-abp can also be used as a library for parsing filter lists. For example |
92 to read a filter list (we use Python 3 syntax here but the API is the same): | 118 to read a filter list (we use Python 3 syntax here but the API is the same): |
93 | 119 |
94 from abp.filters import parse_filterlist | 120 from abp.filters import parse_filterlist |
95 | 121 |
96 with open('filterlist.txt') as filterlist: | 122 with open('filterlist.txt') as filterlist: |
97 for line in parse_filterlist(filterlist): | 123 for line in parse_filterlist(filterlist): |
98 print(line) | 124 print(line) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 > abp <- import("abp.filters.rpy") | 201 > abp <- import("abp.filters.rpy") |
176 | 202 |
177 Now you can use the functions with `abp$functionname`, e.g. | 203 Now you can use the functions with `abp$functionname`, e.g. |
178 `abp.line2dict("@@||g.doubleclick.net/pagead/$subdocument,domain=hon30.org")` | 204 `abp.line2dict("@@||g.doubleclick.net/pagead/$subdocument,domain=hon30.org")` |
179 | 205 |
180 | 206 |
181 [1]: https://adblockplus.org/filters#special-comments | 207 [1]: https://adblockplus.org/filters#special-comments |
182 [2]: http://pytest.org/ | 208 [2]: http://pytest.org/ |
183 [3]: https://tox.readthedocs.org/ | 209 [3]: https://tox.readthedocs.org/ |
184 [4]: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt | 210 [4]: https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt |
OLD | NEW |