Index: /ValBot/check_interwiki_links.py
===================================================================
--- /ValBot/check_interwiki_links.py	(revision 1151)
+++ /ValBot/check_interwiki_links.py	(revision 1152)
@@ -43,5 +43,5 @@
             # Construct full URL for the particular wiki
             iw_url = interwiki_urls[cur] + page_title
-            pywikibot.output('Found {0} link {1}'.format(prefix, page_title))
+            pywikibot.output('Found {0} link {1}.'.format(prefix, page_title))
             iw_found = iw_found + 1
 
@@ -55,5 +55,5 @@
 
             # Test the URL
-            #pywikibot.output('Testing URL {}'.format(iw_url))
+            #pywikibot.output('Testing URL {}...'.format(iw_url))
             response = fetch(iw_url)
 
@@ -61,9 +61,39 @@
             # way we tell that a redirect occurred is by checking the history
             if response.history != []:
-                pywikibot.output('WARNING: Initially got {}.'.format(response.history))
+                pywikibot.output('WARNING: Redirected from {}.'.format(response.history))
                 problems_found = problems_found + 1
             elif response.status_code != 200:
                 #pywikibot.output('WARNING: Got response code {}.'.format(response.status_code)) # commented out because fetch() already prints such a msg
                 problems_found = problems_found + 1
+            elif '#' in page_title:
+                # Isolate section link
+                pywikibot.output('Detected section link on page {0}.'.format(page_title))
+                page_name, anchor_name = page_title.split('#')
+                
+                # Convert dot-notation hex entities to proper characters
+                anchor_name = anchor_name.replace('.22', '"')
+                anchor_name = anchor_name.replace('.27', '\'')
+                anchor_name = anchor_name.replace('.28', '(')
+                anchor_name = anchor_name.replace('.29', ')')
+                
+                # Read linked page to see if it really has this anchor link
+                soup = BeautifulSoup(response.text, 'html.parser')
+                found_section = False
+                for tag in soup.findAll('a'):
+                    link = tag.get('href', None)
+                    if not link:
+                        #pywikibot.output('It is not a link.')
+                        continue
+                    #pywikibot.output('Got link {0}.'.format(link))
+                    if not link.startswith('#'):
+                        continue
+                        
+                    if link == '#' + anchor_name:
+                        pywikibot.output('Found section link!')
+                        found_section = True
+                        break
+                if found_section == False:
+                    pywikibot.output('Could not find section {0} on page {1}.'.format(anchor_name, page_name))
+                    problems_found = problems_found + 1
         cur = cur + 1
 
