File: sitesearch.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--GENHTML INSERT ^^ ================================================================-->
<!--
12/15: Add a doctype spec on line 1 so IE does fixed footer positioning at bottom.
But use HTML 4 (not 5) spec, so images in tables look as they did with no doctype.
Makes some things render diff (e.g, tables at top, and having hdrs), but no worse.
More details: https://en.wikipedia.org/wiki/Quirks_mode#Comparison_of_document_types.
-->
<!--==================================================================================-->

<HTML>

<HEAD>

<!--GENHTML INSERT====================================================================-->

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<!--
For this file only: UTF-8 Unicode encoding for non-ASCII or non-English characters.
Browsers may guess correctly if omitted, but may also use US-ASCII or user settings.
<meta> is used for multiple goals (e.g., http-equiv="Refresh" content="10; URL=...). 
Caution: some files saved with Windows tools may be Latin-1 (windows-1252): see 
their HTML tags, and open/save with care in coding-explicit editors like PyEdit -
opening and saving as UTF-8 blindly may trash Latin-1 quotes, and other text.
-->

<!--
Update Dec-2018: move the <meta> charset (Unicode encoding) declaration above the 
comment here, and the _META_ to the top of <head> if needed, so it's in the first 
1024 bytes of the file.  Else, Firefox issues a warning in its web console, and it 
(and perhaps others) must restart the page parse - a minor performance penalty.
The new form now shows up at byte 736, after _DOCTYPE_ and the standard <> opening.  

The 1024-bytes rule is per HTML5 standard, though other browsers do not complain, 
and all the nonconforming pages worked fine in all 20+ browsers tested.  Lots of 
files at this site have no <meta> charset declaration at all, which is also iffy 
on standards, but Firefox falls back on US-ASCII - as intended by these pages (and
Firefox is being too dogmatic: the web is hardly the place for standards police...).  

This was not an issue in thumbspage result pages, app user guides, showcode response
pages, or unzipped programs' Apache index pages.  It may also be possible to give 
charset (encoding) in an HTTP response instead of <meta> tags, but this site still
has some non-UTF-8 pages, and has limited server control.
-->
<!--==================================================================================-->


<!--GENHTML INSERT===================================================================-->
<!--
Recoded Aug-18 to use relative path, after broken by https:// conversion: can't mix 
http:// page resources (see .htaccess note).  This required regenerating and uploading 
all .html files, but not hundreds of manual page edits - genhtml works.  Formerly 
used ICON-DEFAULT, which has now-dated docs on icon links and filetypes in general;
an icon in the root folder suffices on some (but not all) web servers.
-->

<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />

<!--=================================================================================-->


<!--GENHTML INSERT========================================================-->
<!--
Nov-15: CSS file, code in <HEAD>, for fonts, borders, navbars, etc.
Could also be an in-page <STYLE> sheet, as genhtml pastes any text.
-->

<link rel="stylesheet" type="text/css" href="_main.css">

<!--
Feb-18: add mobile-friendly viewport tag to every page's HEAD.
Fit to device width, no zoom (user may), impacts MANY formats.
Extend STYLE instead of new insert to avoid all-page updates.
Mobile required other redesign: toolbar, code blocks, images,... 
-->
 
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!--======================================================================-->


<!--GENHTML INSERT==================================================================-->
<!--
7/6/14: JS analytics code in <HEAD>, to isolate high-traffic pages, iff JS enabled. 
Former training sites's id: ga('create', 'UA-52578333-1', 'auto').
Book site's id, now used for all: ga('create', 'UA-52579036-1', 'auto').
JavaScript is also used if enabled for thumbspage dynamic image scaling.
-->

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-52579036-1', 'auto');
  ga('send', 'pageview');
</script>

<!--================================================================================-->


<STYLE>

/* sep18: or use "max-width: N%;" for input field - see pylotto.html (but not 95%) */

.inputsize {                              /* 451+: default large (last setting wins) */
    width: 250px;
    border-width: thin;                   /* sep18: or Android Chrome omits at high res */ 
    /* background-color: green; */        /* to test media-query 'clicks' */
}

@media screen and (max-width: 450px) {    /* 351..450: medium input field for mobile */
.inputsize {
    width: 155px;
    /* background-color: blue; */
}
}

@media screen and (max-width: 350px) {    /* 0..350: small input field for mobile */
.inputsize {
    width: 125px;
    /* background-color: red; */
}
}

LI {
    margin-bottom: 8px;    /* add space between, else hard to read+tap (all LI) */
}

A.emph {
    color: black;
}
SPAN.emph {
    background-color: white;     /* wheat? cornsilk? */
    font-weight: bold;           /* bold? normal? */
}
</STYLE>

<TITLE>Search learning-python.com</TITLE>

</HEAD>

<BODY>


<!------------------------------------------------------------------------------------>

<DIV style="background-color: cornsilk;
            border: thin solid black;
            border-left:  0px;
            border-right: 0px;    /* last wins */
">

<H2 style="padding-top: 2px; padding-left: 2px;">Search learning-python.com</H2>

<!-- Jun 2018: add accept-charset to avoid HTML-entity encoding of chars  -->
<!-- outside page's default (though it also changed to UTF-8 for new tip) -->
  
<P>
<FORM method=POST accept-charset="UTF-8" action="cgi/sitesearch.py">
<TABLE border=0 cellpadding=5 bgcolor=tan>

<TR>
  <TH align=right>Search this site:
  <TD><select name=searchsite>
      <option>Entire site
      <!-- Jun 2017: now just one site to rule them all... -->
      <!-- <option>Books only --> 
      <!-- <option>Training only -->
      </select>

<TR>
  <TH align=right>Search for this:
  <!-- Feb 2018: smaller on mobile (was size=50) -->
  <TD><input type=text name=searchterm class=inputsize>    

<TR>
  <!-- in order of preference: see below -->
  <TH align=right>Search provider:
  <TD><select name=searchhost>
      <option>DuckDuckGo
      <option>StartPage
      <option>Google
      <option>Bing
      <option>Yahoo
      <option>Baidu         <!-- Jun 2018: added -->
      <option>Yandex        <!-- Jun 2018: added -->
      <!-- Jun 2018: <option>Ixquick - merged into StartPage in 2016 -->
      </select>

<TR>
  <TH>
  <TD><input type=submit value="Search">

</TABLE>
</FORM>
</P>

</DIV>

<!-- dec18: use border instead of hr so ok in chrome at low zooms
<HR>
-->


<!------------------------------------------------------------------------------------>

<H2 style="margin-top: 30px;">How This Page Works</H2>

<!-- Feb 2018: mobile-friendly viewer, not HREF="sitesearch.py"; -->
<!-- removed the extra copy of the .py in "."; redundancy kills; -->
<P>
When you press this page's Search button, it triggers a Python script on 
the server, which in turn builds a "<I>term</I> site:<I>site</I>" site-specific
search query and passes it to a selected search provider using an HTTP redirect.  
You can view and fetch the code of both sides of this interaction here:

<P style="margin-left: 26px;">
<SPAN class=emph>
<A class=emph HREF="cgi/showcode.py?name=sitesearch.html">this page</A>
&nbsp;⇒&nbsp;
<A class=emph HREF="cgi/showcode.py?name=cgi%2Fsitesearch.py">Python script</A>
</SPAN>

<P>  
The net effect displays results in the provider's 
<A HREF="sitesearch-result.png">page</A>.  The script uses 
basic CGI, and its redirect is a simple technique that leverages work 
already performed by search providers that have crawled the site 
(invited or not).  Assorted tips:

<!-- Jun 2018: add tip about searching for non-ASCII Unicode chars; -->
<!-- use HTML entities for non-BMPs, so works in tools like PyEdit; --> 

<UL>
<LI>To search for Unicode symbols (like  
&#128586;,  <!-- see-no-evil monkey -->
&#128522;,  <!-- a mandatory smiley -->
and ☞), try Google or StartPage first.

<LI>To return to this site, use your browser's Back button on 
the search-results page.

<LI>To read more about redirects, see 
<A HREF="https://en.wikipedia.org/wiki/URL_redirection#Implementation">this</A>,
<A HREF="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">this</A>, and
<A HREF="http://www.w3.org/Protocols/rfc2616/rfc2616.html">this</A>.

<LI>To explore search alternatives, try 
<A HREF="https://duckduckgo.com/search_box">here</A> and 
<A HREF="https://duckduckgo.com/?q=adding+search+to+web+site">here</A>, though
many require JavaScript on the client, PHP on the server, or worse&mdash;per the
next section.
</UL>
<P>


<!------------------------------------------------------------------------------------>

<H2>Search-Provider Cautions</H2>

<P>
Because this page delegates searches to third-parties, it comes with some 
inherent caveats.  First and foremost, some search providers may both 
<I>track</I> searchers, and insert <I>ads</I>  and unrelated <I>photos</I> 
in results.  In testing, Google's search results for "fortran" at this site 
included paid ads for compilers, and Bing displayed pictures of pastry chefs
for "decorators" (yes, really).  Google also disables the Back button in 
some contexts, for reasons not yet isolated.

<!-- Jun 2018: Ixquick was merged into StartPage in 2016 -->
<P>
In light of such constraints, the privacy-respecting sites 
<A href="https://duckduckgo.com/privacy">DuckDuckGo</A> and 
<A HREF="https://www.startpage.com/eng/aboutstartpage/">StartPage</A>
are <I>strongly recommended</I> for users of this page.
Of these, DuckDuckGo seems best in terms of search results so far 
(sometimes finding more than Google), and StartPage seems a close runner-up.
Although other search providers can be selected above for comparison, 
their monetization focus makes them innately perilous, 
and a "use at your own risk" proposition.  

<P>
Search would ideally avoid third parties altogether, of course, but a 
more custom solution is currently outside this site's proprietor's schedule. 
For more on web search privacy options, see 
<A HREF="https://www.expressvpn.com/blog/ixquick-startpage/">this</A>;  
or try a web search...
</P>

<!------------------------------------------------------------------------------------>


<!--GENHTML INSERT==================================================================-->
<!--
Nov15: added via genhtml.py, to avoid pasting footer in every file on changes.
See learning-python.com/genhtml.html for other options and their tradeoffs.
-->

</P>

<!--Feb18: make table responsive, for mobile-friendly scrollbar on small screens -->
<BR><BR>
<DIV class=footerdiv>

<TABLE class=footertable bgcolor=tan width="100%">

<!-- NESTED INSERT: can't nest > 2 deep -->      <!-- gif now is Home, not python.org -->
<TD align=center>                                <!-- border=0 for IE img links       -->
  <A class=blocklinkbar href="index.html">       <!-- scale larger gif for better res -->
  <IMG SRC="PythonPowered.gif" ALT="[Home]" border=0 width=55 height=22></A>  
<TD align=center>
  <A class=blocklinkbar HREF="index-book-links.html">Books</A>
<TD align=center>
  <A class=blocklinkbar HREF="programs.html">Programs</A>
<TD align=center>
  <A class=blocklinkbar HREF="posts.html">Blog</A>
<TD align=center>
  <A class=blocklinkbar HREF="about-python.html">Python</A>
<TD align=center>
  <A class=blocklinkbar HREF="formalbio.html">Author</A>
<TD align=center>
  <A class=blocklinkbar HREF="training.html">Training</A>
<TD align=center>
  <A class=blocklinkbar HREF="sitesearch.html">Search</A>
<TD align=center>
  <A class=blocklinkbar HREF="mailto:lutz@learning-python.com">Email</A>
<!--
<TD align=center>
  <A class=blocklinkbar HREF="#">Top</A>
-->
<TD align=center>
  &copy;<I>M.Lutz</I>
<!-- END NESTED INSERT -->

</TABLE>

</DIV>

<!--================================================================================-->


</BODY></HTML>



[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz