webcheck-strings 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.1
2
+ Name: webcheck_strings
3
+ Version: 0.0.0
4
+ Summary: Monitor text strings on websites
5
+ Home-page: http://ssb22.user.srcf.net/setup/webcheck.html
6
+ Author: Silas S. Brown
7
+ Author-email: ssb22@cam.ac.uk
8
+ License: Apache 2
9
+ Platform: all
10
+ Classifier: Programming Language :: Python :: 2
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=2.3
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+
18
+ WebCheck
19
+ ========
20
+
21
+ From http://ssb22.user.srcf.net/setup/webcheck.html
22
+
23
+ webcheck.py requires Python, and is compatible with both Python 2 and Python 3.
24
+ It is a program to check Web pages for changes to specific phrases of text. I currently use it to:
25
+
26
+ * check that external links from my website still lead to the information that was there when I added them (I might need to update my links otherwise), and check whether or not I need to warn Lynx users about misguided blocking,
27
+ * check the websites of companies, organisations or governments for changes to a specific rule to which I'd be interested in changes (for example because it applies to myself or someone I know, or because I've commented on it somewhere and my comment might need updating),
28
+ * follow a couple of sites' "what's new" RSS feeds in my email,
29
+ * check for new versions of software programs, data files, EPUB publications etc,
30
+ * check if servers hosting my own projects are still serving them,
31
+ * alert me if a private page has somehow been set to public when it shouldn't,
32
+ * check if sentences I've added to "wiki" sites have been changed or deleted (perhaps for good reason, but anyway I want to know),
33
+ * check if code fixes to websites have been accidentally reverted,
34
+ * check if answers or comments I've added to crowd-sourced sites and/or 'blogs have been edited or deleted,
35
+ * check transport websites to see when discounted bookings for a certain date range become available,
36
+ * check if certain rare items I might be interested in appear on an auction site,
37
+ * check to see if Chinese translations have appeared for resources I think my Chinese friends might be interested in,
38
+ * check for any new seminars planned at a couple of locations,
39
+ * check for messages to myself on a couple of websites where I need to log in to check for messages,
40
+ * check for new events planned at a local stadium so I know when the roads are likely to be crowded,
41
+ * check the names of new tenants at a local startup incubator in case I know someone whom I think might be interested in one,
42
+ * check if Android applications I recommend are still on the Play Store, and if their minimum requirements have changed,
43
+ * and various other checks as needed.
44
+
45
+ Some web monitoring programs and “watchlist” facilities etc will tell you when *any* change is made to a page, but that’s of limited use when you are interested in only a few specific phrases, especially when these are surrounded by many other items which change far more frequently than the one that actually interests you. So WebCheck lets you check for changes to a particular item on a page.
46
+
47
+ Note that this is not a “foolproof” method. If a page lists “old news”, or otherwise incorporates an old version of the item you’re monitoring, WebCheck might fail to spot the new situation. You have to use your judgement about when this program can reasonably be used.
48
+
49
+ WebCheck runs from the command line, usually from a cron job or similar, and writes any changes it found to standard output, which can then be emailed or whatever. If using ImapFix (below), try its `--maybenote` option.
50
+
51
+ ## webcheck.list
52
+
53
+ The list of sites to check is in a text file called `webcheck.list`. Each line (apart from blank lines and comments) specifies a URL to fetch and some text to check, optionally followed by a comment (which starts with a space and a `#`). For example:
54
+
55
+ http://nice-program.example.com The latest version is 1.0
56
+
57
+ or
58
+
59
+ http://nice-program.example.com The latest version is 1.0 # otherwise we'd better upgrade
60
+
61
+ If the text starts with a `*` then the rest of it is treated as a regular expression, otherwise it is treated as a simple search.
62
+
63
+ You can check for the absence of certain text by prepending a `!` to it:
64
+
65
+ http://wiki-page.example.org !spam
66
+
67
+ By default, the searches are made against the text on the page, not against its source code. If you want to check the source code, prepend a `>` to the `text` or `!text`.
68
+
69
+ If you need to make more than one test on the same page, simply add multiple lines with the same URL. A shortcut for this is to specify also: on the second and subsequent lines, in place of the repeated URL. Webcheck does of course perform multiple tests in the same fetch operation—the fetch itself will not be duplicated for each test.
70
+
71
+ It is possible to add arbitrary HTTP headers (such as `Accept-Language: en`) on lines of their own; these apply to all subsequently-listed URLs (except when using a Javascript processor, see below) until removed by setting them blank (e.g. `Accept-Language:`). One use of arbitrary headers is to send “cookies” to indicate you’ve accepted the GDPR or whatever: in most graphical browsers’ Developer Options you can go to a Javascript console and type `document.cookie` to find out what to put in the `Cookie:` header to restore your current ‘session’ with the server.
72
+
73
+ It is also possible to add :include directives if you wish to place some of your configuration into other files, e.g. `:include wiki-pages.list` (and if any file such as `webcheck.list` is a directory then the files inside it are read).
74
+
75
+ It is also possible to add simple “or else” logic, for example:
76
+
77
+ http://example.org/page1 my text
78
+ else: http://example.org/page2 my text
79
+
80
+ (this can also be used to retry the same URL if a server works intermittently); unexpected results or errors are reported only from the last `else:` in such a sequence.
81
+
82
+ ## RSS feeds and item lists
83
+
84
+ You can follow new items on RSS/Atom feeds: give the feed URL and *no* search text.
85
+
86
+ If the site lists new items but does not support RSS, you can also *extract* items, by setting the search text to `{START...END}` where `START` and `END` are starting and ending strings that surround each item. (By default this is done on the parsed version of the page; to do it on the HTML source, add a `>` before the `{` at the start of the search text.)
87
+
88
+ ## Basic checks
89
+
90
+ Besides checking `http://`, `https://` and `gemini://` URLs, you can check for:
91
+
92
+ * DNS changes (useful if you’re maintaining a hosts file somewhere due to unreliable DNS or an awkward proxy situation): URLs starting `dns://` will return a list of all current IPs, each enclosed in parentheses. So for example to be alerted if `93.184.216.34` ceases to be one of the IP addresses of `example.com`, use `dns://example.com (93.184.216.34)`
93
+ * Server reachability: if a server has been unreachable for a long time and you want to be alerted if it ever becomes reachable again, you can place `up://` before the URL (e.g. `up://http://www.example.com`) which will return `yes` or `no` and not report an error if the server is not reachable.
94
+ * Misguided blocking of the Lynx browser. Prepend `blocks-lynx://` to a URL to have Webcheck try to fetch it with a Lynx user agent and return `yes` if it gets an error or timeout only with that agent, or `no` otherwise, so you can, at least in a `noscript` tag, warn your visitors that the server to which you link has accidentally started discriminating against blind and other users of the text-only Lynx browser due to misguided security settings—some “example” security configurations of web servers incorrectly assume Lynx implies automation and block it, and staff have been known to copy such examples without review or without realising what blocking Lynx implies.
95
+ * Items in the HTTP HEAD response: prepend `head://` to a URL. This might be useful for checking `Last-Modified` to see if a large download has changed, like `wget -N` but without needing to keep a copy of the file on the machine where your WebCheck runs.
96
+ * Output of arbitrary shell commands: prepend `c://` to the command, and end it with `;` surrounded by spaces
97
+
98
+ ## Using a Javascript processor
99
+
100
+ If the text you wish to check is written by complex Javascript and there’s no simple way to get it out of the site’s source code, and/or if you need to “log in” or perform other interaction to make it available, then you could try installing one of:
101
+
102
+ * Headless Firefox with GeckoDriver,
103
+ * Headless Chrome with ChromeDriver,
104
+ * PhantomJS, or
105
+ * Edbrowse
106
+
107
+ and have WebCheck drive one of these.
108
+
109
+ Edbrowse is more lightweight and should be enough in many cases, but the others have more complete DOM support (see discussion on [Edbrowse issue 4](https://github.com/CMB/edbrowse/issues/4)). In any case you’d be advised to set the check-frequency wisely (see Efficiency section below).
110
+
111
+ For Edbrowse, prepend `e://` to the URL, e.g.:
112
+
113
+ e://http://javascripty-site.example.com my comment
114
+
115
+ Note that checks on the ‘source’ of a rendered DOM (such as checks for class names written by Javascript) are *not* available when using Edbrowse: you’ll have to run Headless Firefox, Headless Chrome or PhantomJS for those.
116
+
117
+ Advanced users of edbrowse can write scripts to perform simple interaction with a Javascript site before reading out the text, provided such interaction does not involve spaces, for example:
118
+
119
+ e://http://javascripty.example.org\/{LOG/\g\/<>/\i=my-username\/<>/\i=myPassword\/<Log/\i*\/{INBOX/\g No messages
120
+
121
+ Here, `/{LOG/` searches for a link whose text begins with ‘LOG’, `g` follows the first link on the current line, `/<>/` searches for empty form fields, `i=` fills them in and `i*` submits; see the edbrowse manual for a full list. `\` is used to separate commands; an implicit `b` (browse) command is added before the start and “print all” at the end. Source is not shown.
122
+
123
+ For Headless Firefox, Headless Chrome or PhantomJS, you need to install the ‘webdriver’ (Selenium) interface. If you need to set it up in your home directory, try `pip install selenium --root $HOME/whatever`, set `PYTHONPATH` appropriately, and put the `phantomjs` or `chromedriver` or `geckodriver` binary in your `PATH` before running webcheck.
124
+
125
+ An instruction to fetch data via Headless Firefox, Headless Chrome or PhantomJS looks like this:
126
+
127
+ { http://site.example.org/ [Click here to show the login form] #txtUsername=me@example.com [#okButton] [Show results] "Results" }
128
+
129
+ where the first word is the starting URL, and items in square brackets will click either a link with that exact text or an element with the `id` or `name` specified after a `#` (check for `id=` or `name=` in a browser’s Document Inspector or similar), or the first element with the `class` specified after a `.` dot (you can specify other elements of a class `someClass` via `.someClass#2` and `.someClass#3` etc). `#id=text` sends keystrokes `text` to an input field with ID (or name) `id` (`.class=text` is also possible), and you can include space by adding a quoted phrase after the `=`. Text in quotes on its own causes the browser to wait until the page source contains it (which is usually necessary when using Headless Firefox, Headless Chrome or PhantomJS, less so with edbrowse); if you'd rather wait a fixed time period, you can specify a number of seconds instead of a quoted string. Also available is `#id->text` to select from a drop-down (by visible text; blank means deselect all; add quotes after the `->` to select a multi-word phrase), and `#id*n` to set a checkbox to state `n` (0 or 1).
130
+
131
+ Some sites make you click each item on a results page to reveal an individual result. To automate this in Headless Firefox, Headless Chrome or PhantomJS, use `/start/5` where ‘start’ is the start of each item ID and 5 is the number of seconds to wait after clicking, or `/.itemClass/5` to perform similarly with a class of elements called `itemClass` (and `.itemClass/.closeClass/5` is also possible if a ‘close’ button of class `closeClass` needs to be pressed to dismiss each result, and you can limit the range of items by adding `:1-47` or `:48-0` etc after the number of seconds, plus if the instruction ends with `!` then any error clicking on an item will be treated as a failure to load the whole page). A snapshot of the page after each click will be added to that of the final page, and the checks (or item extractions) that you specify will occur on the combined result. It’s assumed that no ‘back’ button needs to be pressed between clicks.
132
+
133
+ ## Efficiency
134
+
135
+ To be as efficient as is reasonable for this kind of program, WebCheck has the following features:
136
+
137
+ * Different domains are handled in different threads (up to a maximum of `max_threads`)
138
+ * Connections to the same domain are re-used when possible (with optional `delay`)
139
+ * The program tries to save the “last modified” dates (and optionally the “ETag” values) of pages to a file called `.webcheck-last`, and asks servers not to bother sending pages that haven’t changed at all since the last check
140
+
141
+ However, connection re-use and last-modified handling is *not* performed when using edbrowse or webdriver (except within each session of course).
142
+
143
+ You can also change the frequency of specific checks with the `days` command, which must appear on a line of its own, for example:
144
+
145
+ days 5
146
+
147
+ which specifies that the addresses below that line will be checked only if the day they were previously checked was at least 5 days ago (unless they are also listed in sections that require more frequent checks). For convenience, `daily`, `weekly` and `monthly` are short for `days 1`, `days 7` and `days 30` respectively. If for testing you need to temporarily turn off all frequencies, Last-Modified and ETag checks but not the already-seen RSS items, you can specify `--test-all` on the WebCheck command line.
148
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,130 @@
1
+ from setuptools import setup, find_packages;setup(name='webcheck_strings',version='',entry_points={'console_scripts':['webcheck=webcheck.__init__:main']},license='Apache 2',platforms='all',url='http://ssb22.user.srcf.net/setup/webcheck.html',author='Silas S. Brown',author_email='ssb22@cam.ac.uk',description='Monitor text strings on websites',long_description=r'''WebCheck
2
+ ========
3
+
4
+ From http://ssb22.user.srcf.net/setup/webcheck.html
5
+
6
+ webcheck.py requires Python, and is compatible with both Python 2 and Python 3.
7
+ It is a program to check Web pages for changes to specific phrases of text. I currently use it to:
8
+
9
+ * check that external links from my website still lead to the information that was there when I added them (I might need to update my links otherwise), and check whether or not I need to warn Lynx users about misguided blocking,
10
+ * check the websites of companies, organisations or governments for changes to a specific rule to which I'd be interested in changes (for example because it applies to myself or someone I know, or because I've commented on it somewhere and my comment might need updating),
11
+ * follow a couple of sites' "what's new" RSS feeds in my email,
12
+ * check for new versions of software programs, data files, EPUB publications etc,
13
+ * check if servers hosting my own projects are still serving them,
14
+ * alert me if a private page has somehow been set to public when it shouldn't,
15
+ * check if sentences I've added to "wiki" sites have been changed or deleted (perhaps for good reason, but anyway I want to know),
16
+ * check if code fixes to websites have been accidentally reverted,
17
+ * check if answers or comments I've added to crowd-sourced sites and/or 'blogs have been edited or deleted,
18
+ * check transport websites to see when discounted bookings for a certain date range become available,
19
+ * check if certain rare items I might be interested in appear on an auction site,
20
+ * check to see if Chinese translations have appeared for resources I think my Chinese friends might be interested in,
21
+ * check for any new seminars planned at a couple of locations,
22
+ * check for messages to myself on a couple of websites where I need to log in to check for messages,
23
+ * check for new events planned at a local stadium so I know when the roads are likely to be crowded,
24
+ * check the names of new tenants at a local startup incubator in case I know someone whom I think might be interested in one,
25
+ * check if Android applications I recommend are still on the Play Store, and if their minimum requirements have changed,
26
+ * and various other checks as needed.
27
+
28
+ Some web monitoring programs and “watchlist” facilities etc will tell you when *any* change is made to a page, but that’s of limited use when you are interested in only a few specific phrases, especially when these are surrounded by many other items which change far more frequently than the one that actually interests you. So WebCheck lets you check for changes to a particular item on a page.
29
+
30
+ Note that this is not a “foolproof” method. If a page lists “old news”, or otherwise incorporates an old version of the item you’re monitoring, WebCheck might fail to spot the new situation. You have to use your judgement about when this program can reasonably be used.
31
+
32
+ WebCheck runs from the command line, usually from a cron job or similar, and writes any changes it found to standard output, which can then be emailed or whatever. If using ImapFix (below), try its `--maybenote` option.
33
+
34
+ ## webcheck.list
35
+
36
+ The list of sites to check is in a text file called `webcheck.list`. Each line (apart from blank lines and comments) specifies a URL to fetch and some text to check, optionally followed by a comment (which starts with a space and a `#`). For example:
37
+
38
+ http://nice-program.example.com The latest version is 1.0
39
+
40
+ or
41
+
42
+ http://nice-program.example.com The latest version is 1.0 # otherwise we'd better upgrade
43
+
44
+ If the text starts with a `*` then the rest of it is treated as a regular expression, otherwise it is treated as a simple search.
45
+
46
+ You can check for the absence of certain text by prepending a `!` to it:
47
+
48
+ http://wiki-page.example.org !spam
49
+
50
+ By default, the searches are made against the text on the page, not against its source code. If you want to check the source code, prepend a `>` to the `text` or `!text`.
51
+
52
+ If you need to make more than one test on the same page, simply add multiple lines with the same URL. A shortcut for this is to specify also: on the second and subsequent lines, in place of the repeated URL. Webcheck does of course perform multiple tests in the same fetch operation—the fetch itself will not be duplicated for each test.
53
+
54
+ It is possible to add arbitrary HTTP headers (such as `Accept-Language: en`) on lines of their own; these apply to all subsequently-listed URLs (except when using a Javascript processor, see below) until removed by setting them blank (e.g. `Accept-Language:`). One use of arbitrary headers is to send “cookies” to indicate you’ve accepted the GDPR or whatever: in most graphical browsers’ Developer Options you can go to a Javascript console and type `document.cookie` to find out what to put in the `Cookie:` header to restore your current ‘session’ with the server.
55
+
56
+ It is also possible to add :include directives if you wish to place some of your configuration into other files, e.g. `:include wiki-pages.list` (and if any file such as `webcheck.list` is a directory then the files inside it are read).
57
+
58
+ It is also possible to add simple “or else” logic, for example:
59
+
60
+ http://example.org/page1 my text
61
+ else: http://example.org/page2 my text
62
+
63
+ (this can also be used to retry the same URL if a server works intermittently); unexpected results or errors are reported only from the last `else:` in such a sequence.
64
+
65
+ ## RSS feeds and item lists
66
+
67
+ You can follow new items on RSS/Atom feeds: give the feed URL and *no* search text.
68
+
69
+ If the site lists new items but does not support RSS, you can also *extract* items, by setting the search text to `{START...END}` where `START` and `END` are starting and ending strings that surround each item. (By default this is done on the parsed version of the page; to do it on the HTML source, add a `>` before the `{` at the start of the search text.)
70
+
71
+ ## Basic checks
72
+
73
+ Besides checking `http://`, `https://` and `gemini://` URLs, you can check for:
74
+
75
+ * DNS changes (useful if you’re maintaining a hosts file somewhere due to unreliable DNS or an awkward proxy situation): URLs starting `dns://` will return a list of all current IPs, each enclosed in parentheses. So for example to be alerted if `93.184.216.34` ceases to be one of the IP addresses of `example.com`, use `dns://example.com (93.184.216.34)`
76
+ * Server reachability: if a server has been unreachable for a long time and you want to be alerted if it ever becomes reachable again, you can place `up://` before the URL (e.g. `up://http://www.example.com`) which will return `yes` or `no` and not report an error if the server is not reachable.
77
+ * Misguided blocking of the Lynx browser. Prepend `blocks-lynx://` to a URL to have Webcheck try to fetch it with a Lynx user agent and return `yes` if it gets an error or timeout only with that agent, or `no` otherwise, so you can, at least in a `noscript` tag, warn your visitors that the server to which you link has accidentally started discriminating against blind and other users of the text-only Lynx browser due to misguided security settings—some “example” security configurations of web servers incorrectly assume Lynx implies automation and block it, and staff have been known to copy such examples without review or without realising what blocking Lynx implies.
78
+ * Items in the HTTP HEAD response: prepend `head://` to a URL. This might be useful for checking `Last-Modified` to see if a large download has changed, like `wget -N` but without needing to keep a copy of the file on the machine where your WebCheck runs.
79
+ * Output of arbitrary shell commands: prepend `c://` to the command, and end it with `;` surrounded by spaces
80
+
81
+ ## Using a Javascript processor
82
+
83
+ If the text you wish to check is written by complex Javascript and there’s no simple way to get it out of the site’s source code, and/or if you need to “log in” or perform other interaction to make it available, then you could try installing one of:
84
+
85
+ * Headless Firefox with GeckoDriver,
86
+ * Headless Chrome with ChromeDriver,
87
+ * PhantomJS, or
88
+ * Edbrowse
89
+
90
+ and have WebCheck drive one of these.
91
+
92
+ Edbrowse is more lightweight and should be enough in many cases, but the others have more complete DOM support (see discussion on [Edbrowse issue 4](https://github.com/CMB/edbrowse/issues/4)). In any case you’d be advised to set the check-frequency wisely (see Efficiency section below).
93
+
94
+ For Edbrowse, prepend `e://` to the URL, e.g.:
95
+
96
+ e://http://javascripty-site.example.com my comment
97
+
98
+ Note that checks on the ‘source’ of a rendered DOM (such as checks for class names written by Javascript) are *not* available when using Edbrowse: you’ll have to run Headless Firefox, Headless Chrome or PhantomJS for those.
99
+
100
+ Advanced users of edbrowse can write scripts to perform simple interaction with a Javascript site before reading out the text, provided such interaction does not involve spaces, for example:
101
+
102
+ e://http://javascripty.example.org\/{LOG/\g\/<>/\i=my-username\/<>/\i=myPassword\/<Log/\i*\/{INBOX/\g No messages
103
+
104
+ Here, `/{LOG/` searches for a link whose text begins with ‘LOG’, `g` follows the first link on the current line, `/<>/` searches for empty form fields, `i=` fills them in and `i*` submits; see the edbrowse manual for a full list. `\` is used to separate commands; an implicit `b` (browse) command is added before the start and “print all” at the end. Source is not shown.
105
+
106
+ For Headless Firefox, Headless Chrome or PhantomJS, you need to install the ‘webdriver’ (Selenium) interface. If you need to set it up in your home directory, try `pip install selenium --root $HOME/whatever`, set `PYTHONPATH` appropriately, and put the `phantomjs` or `chromedriver` or `geckodriver` binary in your `PATH` before running webcheck.
107
+
108
+ An instruction to fetch data via Headless Firefox, Headless Chrome or PhantomJS looks like this:
109
+
110
+ { http://site.example.org/ [Click here to show the login form] #txtUsername=me@example.com [#okButton] [Show results] "Results" }
111
+
112
+ where the first word is the starting URL, and items in square brackets will click either a link with that exact text or an element with the `id` or `name` specified after a `#` (check for `id=` or `name=` in a browser’s Document Inspector or similar), or the first element with the `class` specified after a `.` dot (you can specify other elements of a class `someClass` via `.someClass#2` and `.someClass#3` etc). `#id=text` sends keystrokes `text` to an input field with ID (or name) `id` (`.class=text` is also possible), and you can include space by adding a quoted phrase after the `=`. Text in quotes on its own causes the browser to wait until the page source contains it (which is usually necessary when using Headless Firefox, Headless Chrome or PhantomJS, less so with edbrowse); if you'd rather wait a fixed time period, you can specify a number of seconds instead of a quoted string. Also available is `#id->text` to select from a drop-down (by visible text; blank means deselect all; add quotes after the `->` to select a multi-word phrase), and `#id*n` to set a checkbox to state `n` (0 or 1).
113
+
114
+ Some sites make you click each item on a results page to reveal an individual result. To automate this in Headless Firefox, Headless Chrome or PhantomJS, use `/start/5` where ‘start’ is the start of each item ID and 5 is the number of seconds to wait after clicking, or `/.itemClass/5` to perform similarly with a class of elements called `itemClass` (and `.itemClass/.closeClass/5` is also possible if a ‘close’ button of class `closeClass` needs to be pressed to dismiss each result, and you can limit the range of items by adding `:1-47` or `:48-0` etc after the number of seconds, plus if the instruction ends with `!` then any error clicking on an item will be treated as a failure to load the whole page). A snapshot of the page after each click will be added to that of the final page, and the checks (or item extractions) that you specify will occur on the combined result. It’s assumed that no ‘back’ button needs to be pressed between clicks.
115
+
116
+ ## Efficiency
117
+
118
+ To be as efficient as is reasonable for this kind of program, WebCheck has the following features:
119
+
120
+ * Different domains are handled in different threads (up to a maximum of `max_threads`)
121
+ * Connections to the same domain are re-used when possible (with optional `delay`)
122
+ * The program tries to save the “last modified” dates (and optionally the “ETag” values) of pages to a file called `.webcheck-last`, and asks servers not to bother sending pages that haven’t changed at all since the last check
123
+
124
+ However, connection re-use and last-modified handling is *not* performed when using edbrowse or webdriver (except within each session of course).
125
+
126
+ You can also change the frequency of specific checks with the `days` command, which must appear on a line of its own, for example:
127
+
128
+ days 5
129
+
130
+ which specifies that the addresses below that line will be checked only if the day they were previously checked was at least 5 days ago (unless they are also listed in sections that require more frequent checks). For convenience, `daily`, `weekly` and `monthly` are short for `days 1`, `days 7` and `days 30` respectively. If for testing you need to temporarily turn off all frequencies, Last-Modified and ETag checks but not the already-seen RSS items, you can specify `--test-all` on the WebCheck command line.''',long_description_content_type='text/markdown',packages=find_packages(),classifiers=['Programming Language :: Python :: 2','Programming Language :: Python :: 3','License :: OSI Approved :: Apache Software License','Operating System :: OS Independent'],python_requires='>=2.3')