webcheck-strings 1.600__tar.gz → 1.601__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webcheck_strings
3
- Version: 1.600
3
+ Version: 1.601
4
4
  Summary: Monitor text strings on websites
5
5
  Home-page: http://ssb22.user.srcf.net/setup/webcheck.html
6
6
  Author: Silas S. Brown
@@ -88,7 +88,7 @@ If the site lists new items but does not support RSS, you can also *extract* ite
88
88
 
89
89
  Besides checking `http://`, `https://` and `gemini://` URLs, you can check for:
90
90
 
91
- * 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)`
91
+ * 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.215.14` ceases to be one of the IP addresses of `example.com`, use `dns://example.com (93.184.215.14)`
92
92
  * 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.
93
93
  * 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.
94
94
  * 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.
@@ -1,4 +1,4 @@
1
- from setuptools import setup, find_packages;setup(name='webcheck_strings',version='1.600',entry_points={'console_scripts':['webcheck=webcheck.__init__:main']},license='Apache 2',platforms='any',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
1
+ from setuptools import setup, find_packages;setup(name='webcheck_strings',version='1.601',entry_points={'console_scripts':['webcheck=webcheck.__init__:main']},license='Apache 2',platforms='any',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
2
  ========
3
3
 
4
4
  From http://ssb22.user.srcf.net/setup/webcheck.html
@@ -71,7 +71,7 @@ If the site lists new items but does not support RSS, you can also *extract* ite
71
71
 
72
72
  Besides checking `http://`, `https://` and `gemini://` URLs, you can check for:
73
73
 
74
- * 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)`
74
+ * 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.215.14` ceases to be one of the IP addresses of `example.com`, use `dns://example.com (93.184.215.14)`
75
75
  * 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.
76
76
  * 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.
77
77
  * 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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # (compatible with both Python 2 and Python 3)
3
3
 
4
- # webcheck.py v1.6 (c) 2014-24 Silas S. Brown.
4
+ # webcheck.py v1.601 (c) 2014-24 Silas S. Brown.
5
5
  # See webcheck.html for description and usage instructions
6
6
 
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -103,7 +103,7 @@ def read_input():
103
103
  days = 0 ; extraHeaders = []
104
104
  url = mainDomain = None
105
105
  lines = read_input_file()
106
- lastList = None
106
+ lastList = None # refs a list within ret, of [(days,text,elseLogic)]
107
107
  while lines:
108
108
  line = line_withComment = " ".join(lines.pop().split())
109
109
  if " #" in line: line = line[:line.index(" #")].strip()
@@ -167,7 +167,7 @@ def read_input():
167
167
  if isElse:
168
168
  assert lastList, "else without suitable rule before it"
169
169
  lastList[-1] = lastList[-1][:2] + ((url,[(0,text,None)]),) # must be days=0 because don't want to re-check the days count when just retrieved and failed something possibly on same URL ('else:' can be used for simple retrying)
170
- lastList = lastList[-1][2][1] # so 'else' can be used as 'else if'
170
+ lastList = lastList[-1][2][1] # ref the above list (the one after url), so 'else' can be used as 'else if' and next iteration extends it
171
171
  else:
172
172
  lastList = ret.setdefault({
173
173
  # domains to treat as equivalent for rate reduce
@@ -419,13 +419,13 @@ def doJob(opener,delayer,url,checklist,extraHeaders):
419
419
  out=check(t[1:],content,"Source of "+url,"")
420
420
  elif not t or t.startswith('#'):
421
421
  parseRSS(url,content,t.replace('#','',1).strip())
422
- out = None
422
+ out = None # (no else: after real RSS, but you can do else: for no extracted items: that goes through check() above)
423
423
  else:
424
424
  if textContent==None:
425
425
  textContent,errmsg=htmlStrings(content)
426
426
  out=check(t,textContent,url,errmsg)
427
- if out:
428
- if item[2]: toRet.append(item[2])
427
+ if out: # something to alert, unless else:
428
+ if item[2]: toRet.append(item[2]) # else:
429
429
  else: sys.stdout.write(out) # don't use 'print' or may have problems with threads
430
430
  return toRet
431
431
 
@@ -714,7 +714,7 @@ def check(text,content,url,errmsg):
714
714
  if comment: comment="\n "+paren(comment)
715
715
  text = text.strip()
716
716
  assert text # or should have gone to parseRSS instead
717
- if text.startswith('{') and text.endswith('}') and '...' in text: extract(url,content,text[1:-1].split('...'),orig_comment)
717
+ if text.startswith('{') and text.endswith('}') and '...' in text: return extract(url,content,text[1:-1].split('...'),orig_comment)
718
718
  elif text.startswith("!"): # 'not', so alert if DOES contain
719
719
  if len(text)==1: return # TODO: print error?
720
720
  if myFind(text[1:],content):
@@ -820,8 +820,8 @@ def extract(url,content,startEndMarkers,comment):
820
820
  c = content[i+len(start):j].decode('utf-8').strip()
821
821
  if c: items.append(('Auto-extracted text:','',c,"")) # NB the 'title' field must not be empty (unless we relocate that logic to parseRSS instead of handleRSS)
822
822
  i = j+len(end)
823
- if not items: print ("No items were extracted from "+url+" via "+S(start)+"..."+S(end)+" (check that site changes haven't invalidated this extraction rule)")
824
- handleRSS(url,items,comment,"extracted")
823
+ if not items: return ("No items were extracted from "+url+" via "+S(start)+"..."+S(end)+" (check that site changes haven't invalidated this extraction rule)")
824
+ else: handleRSS(url,items,comment,"extracted")
825
825
 
826
826
  def myFind(text,content):
827
827
  text,content = B(text),B(content)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webcheck-strings
3
- Version: 1.600
3
+ Version: 1.601
4
4
  Summary: Monitor text strings on websites
5
5
  Home-page: http://ssb22.user.srcf.net/setup/webcheck.html
6
6
  Author: Silas S. Brown
@@ -88,7 +88,7 @@ If the site lists new items but does not support RSS, you can also *extract* ite
88
88
 
89
89
  Besides checking `http://`, `https://` and `gemini://` URLs, you can check for:
90
90
 
91
- * 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)`
91
+ * 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.215.14` ceases to be one of the IP addresses of `example.com`, use `dns://example.com (93.184.215.14)`
92
92
  * 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.
93
93
  * 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.
94
94
  * 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.