™N
L•;c       sh     d  Z    d Z 	 k Z k Z k Z 
 k Z  k Z  k Z  k Z  d f  d „  ƒ  YZ	 d S(   su   
  Copyright (C) 2000-2001  Brandon Long <blong@fiction.net>

  VirtualBrowser - a controllable/scriptable web agent
s   0.10s   VirtualBrowserc      sƒ     e  d „ Z & d „  Z - d „  Z B e  d e  e  d „ Z  d d „ Z   d „  Z © d	 „  Z ± d
 „  Z ¾ d „  Z	 RS(   Nc    s¤     d t  |  _  t |  _  d |  _  t |  _  h  |  _  h  |  _  d g |  _	  d d d d g |  _
  t i ƒ  |  _ ! d |  _ $ | |  _ d  S(	   Ns   VirtualBrowser/%ss	   localhosts   ens	   text/htmls
   text/plains
   image/jpegs	   image/gifix   (   s   VERSIONs   selfs   _user_agents   Nones   _current_urls   _hosts	   _last_urls   _cookiess   _auth_caches
   _languagess   _typess   urllibs	   URLopeners   _fallback_openers   _timeouts   auth_callbacks   _auth_callback(   s   selfs   auth_callbacks   ./VirtualBrowser.pys   __init__ s   c    sC   & ' y ( t  | ƒ |  _ Wn ) t j
 o
 * n X+ |  Sd  S(   N(   s   ints   os   selfs   _timeouts
   ValueError(   s   selfs   os   ./VirtualBrowser.pys   timeout_& s
   c    s0  - . |  i o / t i |  i | ƒ } n 0 | |  _ 1 t i | ƒ \ } } 2 | o 3 d } n 4 t i	 | ƒ \ } } 5 | o 6 |  i } n 8 | |  _ 9 t i | ƒ \ } } ; | d j oJ < |  i | | | ƒ \ } } }	 }
 = |  i |  _ > | | |	 |
 f Sn @ |  i i | ƒ Sd  S(   Ns   http(   s   selfs	   _last_urls   urllibs   basejoins   urls   _current_urls	   splittypes   types   rests	   splithosts   hosts   paths   _hosts	   splitports   ports
   fetch_https   errcodes   errmsgs   pages   headerss   _fallback_openers   retrieve(   s   selfs   urls   types   rests   hosts   paths   ports   errcodes   errmsgs   pages   headerss   ./VirtualBrowser.pys	   fetchpage- s    $c    sI  B C | o D d } n9 F y G t | ƒ } Wn H t j
 o I d } n XK |  i | | ƒ } M t i	 | | ƒ }	 N |	 i i |  i ƒ O | o P |	 i | | ƒ n R |	 i d | ƒ S |	 i d | ƒ T |	 i d |  i ƒ U |	 i d t i |  i d ƒ ƒ V |	 i d t i |  i d ƒ ƒ W |  i o X |	 i d |  i ƒ n Y | o Z |	 i d	 | ƒ n [ | o0 \ |  i | | ƒ }
 ] |	 i d
 d |
 ƒ n ^ | o | o6 _ |	 i d | ƒ ` |	 i d t t | ƒ ƒ ƒ n b |	 i ƒ  d | o e |	 i | ƒ n g |	 i  ƒ  \ } } } h |	 i$ ƒ  } i | i& ƒ  } j | i( ƒ  l | d j o m | | | | f Sn o | i) d ƒ or s xh | i* d ƒ d s rR } t t i, | d d ƒ \ } } u t/ i0 t i1 | ƒ ƒ } v |  i3 | | ƒ q»Wn x | d j o0 y |  i4 |  _ z | d } { |  i6 | ƒ Sn } | d j oÊ ~ | i) d ƒ o³  | d } € t8 i9 d | ƒ }  | oƒ ‚ | i: ƒ  \ } } ƒ | | d <„ | | d <… t i< | ƒ d j o7 ‡ |  i | | ƒ o ˆ |  i= | | | | ƒ Sn n n n n ‹ | | | | f Sd  S(   NiP   s   GETs   Hosts
   User-Agents   Accepts   , s   Accept-Languages   Referers   Cookies   Authorizations   Basic %ss   Content-Types   Content-Lengthi   s
   set-cookiei    s   :i.  s   locationi‘  s   www-authenticates!   [ 	]*([^ 	]+)[ 	]+realm="([^"]*)"s   virtualbrowser-auth-schemes   virtualbrowser-auth-realms   basic(>   s   ports   ints
   ValueErrors   selfs	   getCookies   hosts   paths   cookies   httplibs   HTTPs   hs   socks   set_timeouts   _timeouts   methods
   putrequests	   putheaders   _user_agents   strings   joins   _typess
   _languagess	   _last_urls   realms   getAuths   auths   bodys   ctypes   strs   lens
   endheaderss   sends   getreplys   errcodes   errmsgs   headerss   getfiles   fs   reads   pages   closes   has_keys   getallmatchingheaderss   lines   splits   headers   values   Cookies   Morsels   strips   ms	   addCookies   _current_urls   newurls	   fetchpages   auth_headers   res   matchs   groupss   schemes   lowers
   fetch_http(   s   selfs   hosts   ports   paths   realms   methods   bodys   ctypes   cookies   hs   auths   errcodes   errmsgs   headerss   fs   pages   lines   headers   values   ms   newurls   auth_headers   matchs   schemes   ./VirtualBrowser.pys
   fetch_httpB sr   
""

#
 	
-s   GETc  
  s-   Ž |  i o  t i |  i | ƒ } n  | |  _ ‘ t i | ƒ \ } } ’ | o “ d } n ” t i	 | ƒ \ } } • | o – |  i } n ˜ | |  _ ™ t i | ƒ \ } } › t i | ƒ }	 œ |  i | | | d d d |	 d | ƒ\ }
 } } }  |  i |  _ ž |
 | | | f Sd  S(   Ns   https   methods   POSTs   bodys   ctype(   s   selfs	   _last_urls   urllibs   basejoins   urls   _current_urls	   splittypes   types   rests	   splithosts   hosts   paths   _hosts	   splitports   ports	   urlencodes	   post_dicts   datas
   fetch_https   ctypes   errcodes   errmsgs   pages   headers(   s   selfs   urls	   post_dicts   ctypes   types   rests   hosts   paths   ports   datas   errcodes   errmsgs   pages   headerss   ./VirtualBrowser.pys   do_post s   6s!   application/x-www-form-urlencodedc    sŒ     ¡ | d t i | ƒ } ¢ |  i i | ƒ o £ |  i | Sn ¤ |  i o/ ¥ |  i \ } } ¦ |  i | | | | ƒ Sn § t Sd  S(   Ns   @(   s   realms   strings   lowers   hosts   keys   selfs   _auth_caches   has_keys   _auth_callbacks   users   passwords   addAuths   None(   s   selfs   hosts   realms   keys   users   passwords   ./VirtualBrowser.pys   getAuth  s   c 	   so   © ª k  } « | d t i | ƒ } ¬ d | | f } ­ t i	 | i
 | ƒ ƒ } ® | |  i | <¯ | Sd  S(   Ns   @s   %s:%s(   s   base64s   realms   strings   lowers   hosts   keys   users   passwords   ups   strips   encodestrings   auths   selfs   _auth_cache(	   s   selfs   hosts   realms   users   passwords   base64s   keys   ups   auths   ./VirtualBrowser.pys   addAuth© s   	c 	   sý   ± ² g  } ³ t | ƒ } ´ xª |  i i ƒ  d ´ r” \ } } µ t | ƒ } ¶ | | | | j o | t | ƒ  | j oJ · x@ |  i | | f d · r& } ¸ | i d | i | i f ƒ q– Wn q0 Wº | g  j o » t Sn ¼ t i | d ƒ Sd  S(   Ni    s   %s=%ss   ; (   s
   cookie_strs   lens   hosts   hlens   selfs   _cookiess   keyss   domains   cpaths   dlens   paths   morsels   appends   keys   values   Nones   strings   join(	   s   selfs   hosts   paths
   cookie_strs   hlens   domains   cpaths   dlens   morsels   ./VirtualBrowser.pys	   getCookie± s   	 / 	,c    s  ¾ ¿ y À | d } Wn Á t j
 o Â | } n XÃ y Ä | d } Wn Å t j
 o Æ d } n XÈ | | f } É |  i i | ƒ ol Ê xK |  i | d Ê r7 } Ë | i
 | i
 j o Ì |  i | i | ƒ n q§ WÍ |  i | i | ƒ n Ï | g |  i | <d  S(   Ns   domains   paths   /i    (   s   morsels   domains   KeyErrors   hosts   paths   uniqs   selfs   _cookiess   has_keys   sms   keys   removes   append(   s   selfs   morsels   hosts   domains   paths   uniqs   sms   ./VirtualBrowser.pys	   addCookie¾ s     	(
   s   Nones   __init__s   timeout_s	   fetchpages
   fetch_https   do_posts   getAuths   addAuths	   getCookies	   addCookie(    s   ./VirtualBrowser.pys   VirtualBrowser s   K	N(
   s   __doc__s   VERSIONs   syss   strings   res   timeoutsockets   urllibs   httplibs   Cookies   VirtualBrowser(    s   ./VirtualBrowser.pys   ? s   					