webcheck-strings 1.601__tar.gz → 1.604__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.
- {webcheck_strings-1.601 → webcheck_strings-1.604}/PKG-INFO +1 -1
- {webcheck_strings-1.601 → webcheck_strings-1.604}/setup.py +1 -1
- {webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck/__init__.py +20 -9
- {webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck_strings.egg-info/PKG-INFO +1 -1
- {webcheck_strings-1.601 → webcheck_strings-1.604}/LICENSE +0 -0
- {webcheck_strings-1.601 → webcheck_strings-1.604}/setup.cfg +0 -0
- {webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck/__main__.py +0 -0
- {webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck_strings.egg-info/SOURCES.txt +0 -0
- {webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck_strings.egg-info/dependency_links.txt +0 -0
- {webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck_strings.egg-info/entry_points.txt +0 -0
- {webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck_strings.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from setuptools import setup, find_packages;setup(name='webcheck_strings',version='1.
|
|
1
|
+
from setuptools import setup, find_packages;setup(name='webcheck_strings',version='1.604',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
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# (compatible with both Python 2 and Python 3)
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
"""webcheck.py v1.604 (c) 2014-25 Silas S. Brown.
|
|
5
|
+
License: Apache 2""" # (see below)
|
|
5
6
|
# See webcheck.html for description and usage instructions
|
|
6
7
|
|
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -103,6 +104,7 @@ def read_input():
|
|
|
103
104
|
days = 0 ; extraHeaders = []
|
|
104
105
|
url = mainDomain = None
|
|
105
106
|
lines = read_input_file()
|
|
107
|
+
if not lines: print ("No input found")
|
|
106
108
|
lastList = None # refs a list within ret, of [(days,text,elseLogic)]
|
|
107
109
|
while lines:
|
|
108
110
|
line = line_withComment = " ".join(lines.pop().split())
|
|
@@ -271,7 +273,7 @@ class Delayer:
|
|
|
271
273
|
def __init__(self,mainDomain):
|
|
272
274
|
self.last_fetch_finished = 0
|
|
273
275
|
if mainDomain=="stackoverflow.com":
|
|
274
|
-
# (or other Stack Exchange sites)
|
|
276
|
+
# (or other Stack Exchange sites as normalised to stackoverflow.com above) (although in 2024-12 I was able to confirm that Stack Exchange's own email notifications of others' edits to your answers _did_ work, so it might not be necessary to monitor for vandalism all your Stack Exchange answers from webcheck)
|
|
275
277
|
self.delay = 80 # seconds between fetches to these sites
|
|
276
278
|
else: self.delay = 3 # (want small if checking many pages and the server doesn't mind, but still non-0)
|
|
277
279
|
def wait(self):
|
|
@@ -403,9 +405,9 @@ def doJob(opener,delayer,url,checklist,extraHeaders):
|
|
|
403
405
|
textContent = None
|
|
404
406
|
delayer.done()
|
|
405
407
|
if content==None: return # not modified (so nothing to report), or problem retrieving (which will have been reported by tryRead0: TODO: return failRet in these circumstances so elseLogic can proceed?)
|
|
406
|
-
if B(content).startswith(B("<!DOCTYPE html>")):
|
|
408
|
+
if B(content).startswith(B("<!DOCTYPE html>")) or B(content).startswith(B('<html lang=')): # check for CloudFlare backoff
|
|
407
409
|
textContent,errmsg=htmlStrings(content)
|
|
408
|
-
if B(textContent)
|
|
410
|
+
if B(textContent).startswith(B("Just a moment...")) and B("Enable JavaScript and cookies to continue") in B(textContent): raise CDNBackoff() # might not be able to check the rest of this domain today
|
|
409
411
|
if u:
|
|
410
412
|
lm = u.info().get("Last-Modified",None)
|
|
411
413
|
if lm: previous_timestamps[(url,'lastMod')] = lm
|
|
@@ -466,6 +468,8 @@ def run_webdriver(ua,actionList,reportErrors):
|
|
|
466
468
|
return B(""), True
|
|
467
469
|
r = "" ; wasError = False
|
|
468
470
|
try: r = run_webdriver_inner(actionList,browser)
|
|
471
|
+
except CDNBackoff:
|
|
472
|
+
browser.quit() ; raise
|
|
469
473
|
except NoTracebackException as e:
|
|
470
474
|
if reportErrors: print (e.message)
|
|
471
475
|
else: wasError = True
|
|
@@ -503,16 +507,20 @@ def run_webdriver_inner(actionList,browser):
|
|
|
503
507
|
return f(browser).encode('utf-8')
|
|
504
508
|
snippets = []
|
|
505
509
|
for a in actionList:
|
|
506
|
-
if a.startswith('http'):
|
|
510
|
+
if a.startswith('http'):
|
|
511
|
+
try: browser.get(a)
|
|
512
|
+
except: raise NoTracebackException("webdriver low-level timeout or error fetching "+a) # e.g. selenium.common.exceptions.TimeoutException
|
|
507
513
|
elif a.startswith('"') and a.endswith('"'):
|
|
508
514
|
# wait for "string" to appear in the source
|
|
509
515
|
tries = 30
|
|
510
516
|
while tries and not myFind(a[1:-1],getSrc()):
|
|
511
517
|
time.sleep(2) ; tries -= 1
|
|
512
518
|
if not tries:
|
|
519
|
+
src = getSrc() ; h=B(htmlStrings(src)[0])
|
|
520
|
+
if h.startswith(B("Just a moment...")) and B("Enable JavaScript and cookies to continue") in h: raise CDNBackoff() # 2024-07: can occur even in webdriver, even though that has JS + cookies
|
|
513
521
|
try: current_url = browser.current_url
|
|
514
522
|
except: current_url = "(unable to obtain)"
|
|
515
|
-
raise NoTracebackException("webdriver timeout while waiting for %s, current URL is %s content \"%s\"\n" % (repr(a[1:-1]),current_url,repr(
|
|
523
|
+
raise NoTracebackException("webdriver timeout while waiting for %s, current URL is %s content \"%s\"\n" % (repr(a[1:-1]),current_url,repr(src))) # don't quote current URL: if the resulting email is viewed in (at least some versions of) MHonArc, a bug can result in " being added to the href
|
|
516
524
|
elif a.startswith('[') and a.endswith(']'): # click
|
|
517
525
|
findElem(a[1:-1]).click()
|
|
518
526
|
elif a.startswith('/') and '/' in a[1:]: # click through items in a list to reveal each one (assume w/out Back)
|
|
@@ -545,7 +553,7 @@ def run_webdriver_inner(actionList,browser):
|
|
|
545
553
|
if sys.stderr.isatty(): sys.stderr.write('*'),sys.stderr.flush()
|
|
546
554
|
except:
|
|
547
555
|
if sys.stderr.isatty(): sys.stderr.write('?'),sys.stderr.flush()
|
|
548
|
-
if propagate_errors: raise NoTracebackException(a+" failed to open instance "+str(curNo))
|
|
556
|
+
if propagate_errors: raise NoTracebackException(a+" failed to open instance "+str(curNo)+" (error because ! is set)")
|
|
549
557
|
else: continue
|
|
550
558
|
time.sleep(delayAfter)
|
|
551
559
|
snippets.append(getSrc())
|
|
@@ -569,7 +577,7 @@ def run_webdriver_inner(actionList,browser):
|
|
|
569
577
|
if sys.stderr.isatty(): sys.stderr.write('*'),sys.stderr.flush() # webdriver's '.' for click-multiple
|
|
570
578
|
except:
|
|
571
579
|
if sys.stderr.isatty(): sys.stderr.write('?'),sys.stderr.flush()
|
|
572
|
-
if propagate_errors: raise NoTracebackException(a+" failed to open instance "+str(curNo))
|
|
580
|
+
if propagate_errors: raise NoTracebackException(a+" failed to open instance "+str(curNo)+" (error because ! is set)")
|
|
573
581
|
else: continue
|
|
574
582
|
time.sleep(delayAfter)
|
|
575
583
|
snippets.append(getSrc())
|
|
@@ -843,4 +851,7 @@ def normalisePunc(t):
|
|
|
843
851
|
]: t=t.replace(s,r)
|
|
844
852
|
return re.sub(B(r"(\s)\s+"),B(r"\1"),t).lower()
|
|
845
853
|
|
|
846
|
-
if __name__=="__main__":
|
|
854
|
+
if __name__=="__main__":
|
|
855
|
+
if "--version" in sys.argv: print(__doc__)
|
|
856
|
+
elif "--help" in sys.argv: print("python webcheck.py [--single-thread] [--test-all] [--show-seen-rss] | --help | --version")
|
|
857
|
+
else: main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck_strings.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{webcheck_strings-1.601 → webcheck_strings-1.604}/webcheck_strings.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|