webcheck-strings 1.59__tar.gz → 1.600__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,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webcheck_strings
3
- Version: 1.59
3
+ Version: 1.600
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
7
7
  Author-email: ssb22@cam.ac.uk
8
8
  License: Apache 2
9
- Platform: all
9
+ Platform: any
10
10
  Classifier: Programming Language :: Python :: 2
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: License :: OSI Approved :: Apache Software License
@@ -20,8 +20,7 @@ WebCheck
20
20
 
21
21
  From http://ssb22.user.srcf.net/setup/webcheck.html
22
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:
23
+ WebCheck is a Python program (compatible with both Python 2 and Python 3) to check Web pages for changes to specific phrases (strings) of text. I currently use it to:
25
24
 
26
25
  * 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
26
  * 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),
@@ -1,10 +1,9 @@
1
- from setuptools import setup, find_packages;setup(name='webcheck_strings',version='1.59',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
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
2
2
  ========
3
3
 
4
4
  From http://ssb22.user.srcf.net/setup/webcheck.html
5
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:
6
+ WebCheck is a Python program (compatible with both Python 2 and Python 3) to check Web pages for changes to specific phrases (strings) of text. I currently use it to:
8
7
 
9
8
  * 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
9
  * 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),
@@ -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.59 (c) 2014-24 Silas S. Brown.
4
+ # webcheck.py v1.6 (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");
@@ -29,7 +29,6 @@
29
29
  # and in China: https://gitee.com/ssb22/web-imap-etc
30
30
 
31
31
  max_threads = 10
32
- delay = 80 # seconds between fetches on same domain-set
33
32
  keep_etags = False # if True, will also keep any ETag headers as well as Last-Modified
34
33
  verify_SSL_certificates = False # webcheck's non-Webdriver URLs are for monitoring public services and there's not a lot of point in SSL authentication; failures due to server/client certificate misconfigurations are more trouble than they're worth
35
34
 
@@ -237,7 +236,8 @@ def main():
237
236
 
238
237
  # 1 job per domain:
239
238
  global jobs ; jobs = Queue.Queue()
240
- for v in read_input().values(): jobs.put(v)
239
+ for mainDomain,jobItems in read_input().items():
240
+ jobs.put((mainDomain,jobItems))
241
241
 
242
242
  global previous_timestamps
243
243
  try: previous_timestamps = pickle.Unpickler(open(".webcheck-last","rb")).load()
@@ -268,19 +268,24 @@ default_ua = 'Mozilla/5.0 or whatever you like (actually Webcheck)'
268
268
  # people to hide their tools from webmasters unnecessarily.
269
269
 
270
270
  class Delayer:
271
- def __init__(self): self.last_fetch_finished = 0
271
+ def __init__(self,mainDomain):
272
+ self.last_fetch_finished = 0
273
+ if mainDomain=="stackoverflow.com":
274
+ # (or other Stack Exchange sites)
275
+ self.delay = 80 # seconds between fetches to these sites
276
+ else: self.delay = 3 # (want small if checking many pages and the server doesn't mind, but still non-0)
272
277
  def wait(self):
273
- time.sleep(max(0,self.last_fetch_finished+delay-time.time()))
278
+ time.sleep(max(0,self.last_fetch_finished+self.delay-time.time()))
274
279
  if sys.stderr.isatty(): sys.stderr.write('.'),sys.stderr.flush()
275
280
  def done(self): self.last_fetch_finished = time.time()
276
281
 
277
282
  def worker_thread(*args):
278
283
  opener = [None]
279
284
  while True:
280
- try: job = jobs.get(False)
285
+ try: mainDomain,job = jobs.get(False)
281
286
  except: return # no more jobs left
282
287
  try:
283
- delayer = Delayer()
288
+ delayer = Delayer(mainDomain)
284
289
  items = sorted(job.items()) # sorted will group http and https together
285
290
  items.reverse()
286
291
  while items:
@@ -306,6 +311,7 @@ def worker_thread(*args):
306
311
  jobs.task_done()
307
312
  class CDNBackoff(Exception): pass
308
313
 
314
+ import threading ; lock = threading.Lock() # webcheck-debug
309
315
  def doJob(opener,delayer,url,checklist,extraHeaders):
310
316
  failRet = [c[2] for c in checklist if c[2]]
311
317
  delayer.wait()
@@ -502,7 +508,7 @@ def run_webdriver_inner(actionList,browser):
502
508
  # wait for "string" to appear in the source
503
509
  tries = 30
504
510
  while tries and not myFind(a[1:-1],getSrc()):
505
- time.sleep(delay) ; tries -= 1
511
+ time.sleep(2) ; tries -= 1
506
512
  if not tries:
507
513
  try: current_url = browser.current_url
508
514
  except: current_url = "(unable to obtain)"
@@ -586,7 +592,7 @@ def run_webdriver_inner(actionList,browser):
586
592
  elif re.match("[0-9]+$",a): time.sleep(int(a))
587
593
  else: sys.stdout.write("Ignoring webdriver unknown action "+repr(a)+'\n')
588
594
  if sys.stderr.isatty(): sys.stderr.write(':'),sys.stderr.flush() # webdriver's '.'
589
- time.sleep(delay)
595
+ time.sleep(2)
590
596
  snippets.append(getSrc())
591
597
  return B('\n').join(snippets)
592
598
 
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webcheck-strings
3
- Version: 1.59
3
+ Version: 1.600
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
7
7
  Author-email: ssb22@cam.ac.uk
8
8
  License: Apache 2
9
- Platform: all
9
+ Platform: any
10
10
  Classifier: Programming Language :: Python :: 2
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: License :: OSI Approved :: Apache Software License
@@ -20,8 +20,7 @@ WebCheck
20
20
 
21
21
  From http://ssb22.user.srcf.net/setup/webcheck.html
22
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:
23
+ WebCheck is a Python program (compatible with both Python 2 and Python 3) to check Web pages for changes to specific phrases (strings) of text. I currently use it to:
25
24
 
26
25
  * 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
26
  * 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),