title: Python - Unable to Send Post Request to login form
body: <p>I am trying to send a POST message to login to a web interface, get authenticated, and use the cookie to download available historical data on the device.</p>
  
  <p>Issue: My POST request does not seem to be working because the code keeps unable to get authenticated and returns the login source page content and there is no cookie. I think the form data I am using is incorrect but not sure what is wrong?</p>
  
  <pre><code>from requests import session
  
  payload = {
      'action': 'login_form',
      'login_user': 'niino4879',
      'login_password': 'password' #Not the actual password . :)
  }
  
  with session() as c:
      c.post('https://secure.advfn.com/login/secure', data=payload)
      response = c.get('https://mx.advfn.com/bolsa-de-valores/BMV/homex-HOMEX*/historico/descargar')
      print(response.headers)
      print(response.text)
      with open('response1.csv', 'wb') as itd:
              itd.write(response.content)
              itd.close()
  </code></pre>
  
  <p><strong>Source code of the device's login web interface</strong></p>
  
  <pre><code>&lt;div class="wr wr-login"&gt;
      &lt;div class="ct"&gt;
              &lt;div id="formPage_wrapper"&gt;
                  &lt;div id="login_form" class="Element LoginElement "&gt;&lt;div id="login_form_element"&gt;
  
      &lt;div id="login_error"&gt;Sesión incorrecta - trate de nuevo&lt;/div&gt;
      &lt;div id="preloader" style="text-align:center;display:none; margin-bottom:10px;"&gt;&lt;img id="indicator" style="display:inline;" src="/common/images/bgs/ajax-loader.gif" alt="loading"&gt;&lt;/div&gt;
      &lt;div id="form_group_wrapper"&gt;
          &lt;div class="col col-1"&gt;
              &lt;div id="form_wrapper"&gt;
                  &lt;form action="https://secure.advfn.com/login/secure" id="login_form" name="login_form" method="POST" target=""&gt;
  
                  &lt;input type="hidden" value="aHR0cHM6Ly9teC5hZHZmbi5jb20vY29tbW9uL2FjY291bnQvbG9naW4=" name="redirect_url" id="redirect_url"&gt;
                  &lt;input type="hidden" value="mx" name="site" id="site"&gt;
  
                  &lt;div class="fields"&gt;
                  &lt;label for="login_username"&gt;Usuario&lt;/label&gt; 
                      &lt;input type="text" tabindex="1" class="text ui-widget-content" value="niino4879" id="login_username" name="login_username" maxlength="64"&gt;
                  &lt;/div&gt;
  
                  &lt;div class="fields"&gt;
                  &lt;label for="login_password"&gt;Contraseña&lt;/label&gt; 
                      &lt;input tabindex="2" type="password" class="text ui-widget-content" value="" id="login_password" name="login_password" maxlength="16"&gt;
                  &lt;/div&gt;
  
                  &lt;div class="fields lost-pass"&gt;
                      &lt;strong&gt;&lt;a href="/common/account/password/request"&gt;¿Olvido su contraseña?&lt;/a&gt;&lt;/strong&gt; &amp;nbsp;
                      &lt;input class="button" tabindex="3" type="submit" value="Iniciar" id="login_submit"&gt;
                  &lt;/div&gt;
              &lt;/form&gt; 
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="col col-2"&gt;
          &lt;ul id="support_links"&gt;&lt;li&gt;&lt;a href="mailto:soporte@advfn.mx?subject=Ayuda Sesion" title="Contactar soporte al cliente"&gt;soporte@advfn.mx&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
      &lt;/div&gt;
      &lt;div class="fields create-account"&gt;&lt;span class="break"&gt;¿No tienes una cuenta?&lt;/span&gt; &lt;span class="break"&gt; &lt;a href="/common/account/register"&gt; Crea una ahora&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I see the form action: </p>
  
  <pre><code>&lt;form action="https://secure.advfn.com/login/secure" id="login_form" name="login_form" method="POST" target=""&gt;
  </code></pre>
  
  <p><strong>This is the Source Code after successful authentication</strong> <strong>( Logged in manually )</strong></p>
  
  <pre><code>&lt;html lang="es-MX"&gt;&lt;head&gt;&lt;iframe sandbox="allow-scripts allow-same-origin" id="23c7310400b0c86" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="//acdn.adnxs.com/ib/static/usersync/v3/async_usersync.html"&gt;
      &lt;/iframe&gt;&lt;iframe sandbox="allow-scripts allow-same-origin" id="22d11e897c80e36" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="//biddr.brealtime.com/check.html"&gt;
      &lt;/iframe&gt;&lt;iframe sandbox="allow-scripts allow-same-origin" id="21073be26d3bdb4" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="//ap.lijit.com/beacon?informer=8910925&amp;amp;gdpr_consent="&gt;
      &lt;/iframe&gt;&lt;iframe sandbox="allow-scripts allow-same-origin" id="20739ed2b398108" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0px;width:0px;display:none;" scrolling="no" src="https://eus.rubiconproject.com/usync.html"&gt;
      &lt;/iframe&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
  
  &lt;!-- APS_HEADER_START --&gt;
  &lt;script src="https://www.googletagservices.com/activeview/js/current/osd.js?cb=%2Fr20100101"&gt;&lt;/script&gt;&lt;script src="https://securepubads.g.doubleclick.net/gpt/pubads_impl_rendering_289.js?21062969"&gt;&lt;/script&gt;&lt;script async="" src="https://sb.scorecardresearch.com/beacon.js"&gt;&lt;/script&gt;&lt;script type="text/javascript" async="" src="https://www.google-analytics.com/plugins/ua/linkid.js"&gt;&lt;/script&gt;&lt;script async="" src="//www.google-analytics.com/analytics.js"&gt;&lt;/script&gt;&lt;script async="" type="text/javascript" src="https://www.googletagservices.com/tag/js/gpt.js"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];
  var pbjs = pbjs || {};
  pbjs.que = pbjs.que || [];
  &lt;/script&gt;
  
  &lt;script type="text/javascript" src="/common/javascript/postscribe.min.js?v=20190111170913_8d76dbb6fa6c3c90c6e8358070b9999a"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript" src="/common/javascript/prebid.js?v=20190111170913_8d76dbb6fa6c3c90c6e8358070b9999a"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  var aps = aps || {"adUnits":[{"type":5,"pos":1,"id":"APS_TOP_BANNER_468_X_60","adSlot":"\/2495092\/ADVFN_mx_ros_1","width":728,"height":90},{"type":5,"pos":30,"id":"APS_RIGHT_SKY_120_X_600","adSlot":"\/2495092\/ADVFN_mx_ros_30","width":120,"height":600},{"type":5,"pos":80,"id":"APS_300_X_250","adSlot":"\/2495092\/ADVFN_mx_ros_80","width":300,"height":250},{"type":5,"pos":810,"id":"APS_MPU_FOOTER","adSlot":"\/2495092\/ADVFN_mx_ros_810","width":300,"height":250},{"type":5,"pos":813,"id":"APS_BILLBOARD_FOOTER","adSlot":"\/2495092\/ADVFN_mx_global_813","width":970,"height":250},{"type":5,"pos":3000,"id":"APS_MOBILE_320x50","adSlot":"\/4196578\/ADVFN_APP_Banner","width":320,"height":50}],"site":"advfn","view":"mx","pid":"datadown","targeting":{"COOKIE":1,"known_user":1,"UL":30,"bp":1,"MKTAK":"fE1YfFJFR3xCTVZfTDF8Qk1WX0wyfFBCQnxNT05fTUFJTEVSfGtub3duX3VzZXI9MXxVTD0zMHxwYWdlX3BhdGg9L2JvbHNhLWRlLXZhbG9yZXMvQk1WL2hvbWV4LUhPTUVYKi9oaXN0b3JpY28vZGVzY2FyZ2FyfHN5bWJvbD1IT01FWCp8bWFya2V0PUJNVnw%3D","MKTAS":860,"symbol":"BMV%3AHOMEX%2A","symbol_type":"DE","market":"BMV","staff":"","eu":0,"geo":"MX","pid":"datadown"},"enabled":true,"openx_enabled":false,"prebid_enabled":true}
  &lt;/script&gt;
  
  &lt;script type="text/javascript" src="/common/javascript/aps.min.js?v=20190111170913_8d76dbb6fa6c3c90c6e8358070b9999a"&gt;&lt;/script&gt;
  &lt;!-- APS_HEADER_END --&gt;&lt;meta name="format-detection" content="telephone=no"&gt;
  &lt;meta name="robots" content="noindex,nofollow"&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;ADVFN - Descarga de Datos&lt;/title&gt;
  &lt;link rel="canonical" href="https://mx.advfn.com/bolsa-de-valores/BMV/homex-HOMEX*/historico/descargar"&gt;
  &lt;link rel="search" href="/common/opensearch/index" type="application/opensearchdescription+xml" title="ADVFN Share Price Search"&gt;
  &lt;link rel="stylesheet" href="/style.css?v=20190111170913_8d76dbb6fa6c3c90c6e8358070b9999a"&gt;
  &lt;link rel="stylesheet" href="/common/elements/css/symbol-title-element.css?v=20190111170913_8d76dbb6fa6c3c90c6e8358070b9999a"&gt;
  &lt;script type="text/javascript"&gt;
  (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-25061202-1',{'cookieDomain':'advfn.com'});
  ga('require', 'linkid', 'linkid.js');
  ga('set', 'dimension4', '3');
  
  ga('send', 'pageview', '/' + 'data_downloads' + '/' + 'original');
  &lt;/script&gt;&lt;link rel="preload" href="https://adservice.google.com.mx/adsid/integrator.js?domain=mx.advfn.com" as="script"&gt;&lt;script type="text/javascript" src="https://adservice.google.com.mx/adsid/integrator.js?domain=mx.advfn.com"&gt;&lt;/script&gt;&lt;link rel="preload" href="https://adservice.google.com/adsid/integrator.js?domain=mx.advfn.com" as="script"&gt;&lt;script type="text/javascript" src="https://adservice.google.com/adsid/integrator.js?domain=mx.advfn.com"&gt;&lt;/script&gt;&lt;script src="https://securepubads.g.doubleclick.net/gpt/pubads_impl_289.js?21062969" async=""&gt;&lt;/script&gt;
  
  &lt;script src="/common/generatedJS/ee9fa05b3336d6daae868d31ef0f047d.js?classes=_Common|_jQuery" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      if(typeof Locale !== 'undefined')
          var localeObj = new Locale('es_MX');
  &lt;/script&gt;
  &lt;script type="text/javascript" src="/script.js?v=20190111170913_8d76dbb6fa6c3c90c6e8358070b9999a"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  &lt;!--
  if(window!=top)
      top.location.href=location.href;
  // --&gt;
  &lt;/script&gt;
  &lt;script language="javascript"&gt;
  &lt;!--
  function doSubmit() {if(document.forms[0].btn.value == "" ) {document.forms[0].btn.value="s_ok"; return true;} else { return true; } }// --&gt;
  &lt;/script&gt;
  &lt;link rel="prefetch" href="https://tpc.googlesyndication.com/safeframe/1-0-31/html/container.html"&gt;&lt;/head&gt;
  &lt;body id="afnmainbodid" style="margin:0 5px 5px 5px" onload=" " bgcolor="white" link="#2b3266" vlink="black"&gt;
  &lt;form name="afnmain" id="mainRegForm" enctype="application/x-www-form-urlencoded" action="/p.php" method="GET" onsubmit="return doSubmit();"&gt;
  &lt;input type="hidden" name="pid" value="datadown"&gt;
  &lt;input type="hidden" name="btn" value=""&gt;
  &lt;link rel="stylesheet" type="text/css" href="/common/styles/header.css?v=20151021"&gt;
  
  &lt;span id="header-container"&gt;
      &lt;aside id="header-menu"&gt;
          &lt;div class="main-nav-search"&gt;
              &lt;span id="logo-area"&gt;
                  &lt;header&gt;
                      &lt;h1&gt;
                          &lt;a href="/" title="Página de Incio ADVFN" style="background: url(/common/images/logos/advfn_112x29.png) no-repeat 0 0;"&gt;ADVFN PLC&lt;/a&gt;
                      &lt;/h1&gt;
                  &lt;/header&gt;
              &lt;/span&gt;
              &lt;div id="header-search-wrapper"&gt;
                  &lt;span id="header-quote-search"&gt;
                              &lt;input class="advfn-autosuggest rounded" type="text" autocomplete="off" maxlength="16" id="headerQuickQuoteSearch" data-pid="datadown" placeholder="Ingrese símbolo" data-trigger-click="header-search-btn" data-cip-id="headerQuickQuoteSearch"&gt;&lt;div id="headerQuickQuoteSearch-menu" class="autosuggest-menu" tabindex="1" style="display: none; top: 35.9948px; left: 0px;"&gt;&lt;table tabindex="2" class="autosuggest-results"&gt;&lt;/table&gt;&lt;/div&gt;
          &lt;button id="header-search-btn" type="button"&gt;&lt;div id="quickQuoteSearchMagnifylens"&gt;&lt;/div&gt;&lt;/button&gt;
                      &lt;span id="header-button-area"&gt;
                          &lt;a href="//mx.advfn.com/p.php?pid=prodmatrix&amp;amp;xref=header_upgrade" class="menu-upgrade-button"&gt;Pruebe Tiempo Real&lt;/a&gt;
                      &lt;/span&gt;
                  &lt;/span&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;nav&gt;
              &lt;ul class="mainnav"&gt;
                  &lt;li class="menu dropdown"&gt;&lt;span class="menu-dropdown"&gt;Menu&lt;/span&gt;&lt;div id="menu-content"&gt;&lt;div id="menu-tool"&gt;&lt;a href="/p.php?pid=pf"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/portfolio.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Portafolio&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/alarmas"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/alarms.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Alarmas&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/insights/toplist/BMV/volume/charts"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/ranking.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Ranking&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/p.php?pid=news"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/news.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Noticias&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/p.php?pid=forex"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/forex.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Forex&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/currency-converter/"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/curr_convt.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Convertidor de Divisas&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/p.php?pid=commodities"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/commodities.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Commodities&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/insights/trader-alerts"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 80px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/trader-alert.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Alarmas Trader&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/preguntas-respuestas/"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 85px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/qa.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Preguntas y Respuestas&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;a href="/criptodivisas"&gt;&lt;div class="menu-tool-icon-wrapper" style="width: 85px;"&gt;&lt;div class="menu-tool-icon" style="background-image: url(&amp;quot;/common/images/header/tools/bitcoin.png&amp;quot;);"&gt;&lt;/div&gt;&lt;div class="menu-tool-text"&gt;Criptodivisas&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="menu-monitor"&gt;&lt;a href="//mx.advfn.com/p.php?pid=mon" title="Cotizaciones Multiples en streaming y tiempo real de la Bolsa Mexicana y otras bolsas internacionales"&gt;Monitor&lt;/a&gt;&lt;/li&gt;&lt;li class="menu-chart"&gt;&lt;a href="//mx.advfn.com/p.php?pid=charts" title="Graficas en streaming y tiempo real de la Bolsa Mexicana"&gt;Gráficas&lt;/a&gt;&lt;/li&gt;&lt;li class="menu-level2"&gt;&lt;a href="//mx.advfn.com/p.php?pid=level2" title="Formador de Mercado cotizaciones y libro de órdenes"&gt;Nivel 2&lt;/a&gt;&lt;/li&gt;&lt;li class="menu-afores"&gt;&lt;a href="//mx.advfn.com/educacion/afores-informacion-y-comparaciones" title="Calcule sus rendimientos con las diferentes Afores"&gt;Afores&lt;/a&gt;&lt;/li&gt;&lt;li class="world dropdown"&gt;&lt;span class="menu-dropdown"&gt;Mundial&lt;/span&gt;&lt;ul&gt;&lt;li class="odd first"&gt;&lt;a href="/mundo"&gt;&lt;img src="//images.advfn.com/imagesnew/2/us/front/globe.gif"&gt;Mundo&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/mundo/alemania"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/de.gif"&gt;Alemania&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/mundo/australia"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/au.gif"&gt;Australia&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/mundo/brasil"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/br.gif"&gt;Brasil&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/mundo/canada"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/ca.gif"&gt;Canadá&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/mundo/eeuu"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/us.gif"&gt;EEUU&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/mundo/europa"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/eu.gif"&gt;Europa&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/mundo/filipinas"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/ph.gif"&gt;Filipinas&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/mundo/francia"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/fr.gif"&gt;Francia&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/mundo/grecia"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/gr.gif"&gt;Grecia&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/mundo/holanda"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/nl.gif"&gt;Holanda&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/mundo/italia"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/it.gif"&gt;Italia&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/mundo/mexico"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/mx.gif"&gt;México&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/mundo/portugal"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/pt.gif"&gt;Portugal&lt;/a&gt;&lt;/li&gt;&lt;li class="odd last"&gt;&lt;a href="/mundo/reinounido"&gt;&lt;img src="//images.advfn.com/imagesnew/2/gb/flags/3d/gb.gif"&gt;Reino Unido&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li class="followfeed-menu"&gt;&lt;a href="//mx.advfn.com/follow-feed" title="Follow Feed"&gt;Follow Feed&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
              &lt;ul class="userbox"&gt;
                  &lt;li class="user dropdown"&gt;
                      &lt;span class="user-span" style="background-image: url(&amp;quot;//mx.advfn.com/p.php?pid=profilepic&amp;amp;user=niino4879&amp;quot;);"&gt;niino4879&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="//mx.advfn.com/forum/perfil" title=""&gt;Mi Perfil&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="//mx.advfn.com/common/messages" title=""&gt;Mensajes&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="//mx.advfn.com/common/settings" title=""&gt;Preferencias&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="mailto:soporte@advfn.mx?subject=Ayuda sobre el sitio" title="Contáctenos"&gt;Contáctenos&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="//mx.advfn.com/tel:(55) 4170 8128" class="menu-support-phone"&gt;Llámenos&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="//mx.advfn.com" onclick="menuShowLiveChat(); return false;"&gt;Chat en vivo&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="//mx.advfn.com/p.php?pid=front&amp;amp;logout=1" title=""&gt;Cerrar Sesión&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
  
          &lt;/nav&gt;
      &lt;/aside&gt;
  &lt;/span&gt;
  
  &lt;div id="notification-zone" class="Element NotificationZoneElement "&gt;&lt;/div&gt;
  
  
  
          &lt;aside class="APS_TOP_BANNER_468_X_60_container"&gt;
              &lt;div class="APS_TOP_BANNER_468_X_60_container"&gt;
                  &lt;div style="width: 728px; margin:15px auto;"&gt;
  &lt;div id="APS_TOP_BANNER_468_X_60" class="dfpAd APS_TOP_BANNER_468_X_60" curpage="datadown" page="apsglobalads" pos="1" view="mx" data-google-query-id="CO7u67vz7d8CFQmyTwodT4sLIg"&gt;&lt;div id="google_ads_iframe_/2495092/ADVFN_mx_ros_1_0__container__" style="border: 0pt none;"&gt;&lt;iframe id="google_ads_iframe_/2495092/ADVFN_mx_ros_1_0" title="3rd party ad content" name="google_ads_iframe_/2495092/ADVFN_mx_ros_1_0" width="728" height="90" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" srcdoc="" style="border: 0px; vertical-align: bottom;" data-google-container-id="1" data-load-complete="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/aside&gt;
          &lt;script type="text/javascript"&gt;
          var NOT_PINNED = false;
          var APS_TOP_BANNER_468_X_60 = {
              element: $('div.APS_TOP_BANNER_468_X_60_container'),
              offset: 0,
              top: 0,
              scroll: function(){
                  var pos = $(document).scrollTop();
                  if(pos &gt; APS_TOP_BANNER_468_X_60.offset) {
                      APS_TOP_BANNER_468_X_60.element.css({'position':'fixed', 'top': APS_TOP_BANNER_468_X_60.top});
                      APS_TOP_BANNER_468_X_60.startTimer();
                  }
                  else{
                      APS_TOP_BANNER_468_X_60.element.css({'position':'relative', 'top': 'auto'});
                  }
              },
              stop: function(){
                  $(window).off("scroll", APS_TOP_BANNER_468_X_60.initScroll);
                  return;
              },
              init: function() {
                  APS_TOP_BANNER_468_X_60.checkScrollTimer = window.setTimeout(function() { APS_TOP_BANNER_468_X_60.stop() }, 4000);
                  $(window).on("scroll", APS_TOP_BANNER_468_X_60.initScroll);
              },
              initScroll: function(){
                  if(typeof(APS_TOP_BANNER_468_X_60.checkScrollTimer)=='number')
                  {
                      window.clearTimeout( APS_TOP_BANNER_468_X_60.checkScrollTimer );
                      $(window).off("scroll", APS_TOP_BANNER_468_X_60.initScroll);
                  }
                  APS_TOP_BANNER_468_X_60.top = APS_TOP_BANNER_468_X_60.element.offset().top;
                  var mobileAppBanner = $('#smartbanner');
                  if (mobileAppBanner.length &gt; 0 &amp;&amp; $(mobileAppBanner).is(':visible')){
                      APS_TOP_BANNER_468_X_60.offset = 82;
                  }
                  $(window).on("scroll", APS_TOP_BANNER_468_X_60.scroll);
                  $('aside.APS_TOP_BANNER_468_X_60_container').addClass('fixed');
              },
              startTimer: function(){
                  if(typeof(APS_TOP_BANNER_468_X_60.timer)=='undefined')
                  {
                      APS_TOP_BANNER_468_X_60.timer = window.setTimeout(function() { APS_TOP_BANNER_468_X_60.stopScroll() }, 3000);
                  }
              },
              stopScroll:function(){
                  window.clearTimeout( APS_TOP_BANNER_468_X_60.timer );
                  $(window).off("scroll", APS_TOP_BANNER_468_X_60.scroll);
                  APS_TOP_BANNER_468_X_60.timer=false;
                  APS_TOP_BANNER_468_X_60.element.fadeOut(400, function() {
                      APS_TOP_BANNER_468_X_60.element.css({'position':'relative', 'top': 'auto'}).fadeIn();
                  });
                  $('aside.APS_TOP_BANNER_468_X_60_container').removeClass('fixed');
              }
          }
          APS_TOP_BANNER_468_X_60.init();
          &lt;/script&gt;
  
  
  
  &lt;div style="width:994px; margin:0px auto"&gt;&lt;div id="breadcrumb" class="Element DRBreadcrumbElement "&gt;&lt;/div&gt;&lt;div id="quote-menu" class="Element LinkListElement TabMenuElement "&gt;&lt;ul&gt;&lt;li class="odd first"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/cotizacion" title="Cotizaciones para las Acciones Homex"&gt;Cotización&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/grafica/tiempo-real" title="Gráfica de HOMEX*"&gt;Gráfica&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/profundidad-de-mercado" title="Profundidad de Mercado. para HOMEX*"&gt;Profundidad de Mercado&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/operaciones" title="Operacioens para HOMEX*"&gt;Operaciones&lt;/a&gt;&lt;/li&gt;&lt;li class="odd"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/noticias" title="Noticias sobre Homex"&gt;Noticias&lt;/a&gt;&lt;/li&gt;&lt;li class="even"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/financieros" title="Información Financiera for Homex"&gt;Infomación Financiera&lt;/a&gt;&lt;/li&gt;&lt;li class="odd selected last"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/historico" title="Histórico de Datos para HOMEX*"&gt;Histórico&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div id="toolbar"&gt;&lt;select name="symbol_alt" onchange="javascript:location.href=this.value;" style="width:250px" data-cip-id="cIPJQ342845639"&gt;&lt;option selected=""&gt;Desarrolladora Homex, S.A.B. de C.V. (BMV)&lt;/option&gt;&lt;/select&gt;&lt;input type="text" name="symbol" class="advfn-autosuggest" id="symbol_entry" value="BMV:HOMEX*" onkeypress="return disableEnterKey(event, this.value, 'datadown');" style="width:150px" spellcheck="false" autocomplete="off" data-cip-id="symbol_entry"&gt;&lt;div id="symbol_entry-menu" class="autosuggest-menu" tabindex="1" style="display: none; top: 300.313px; left: 263.984px;"&gt;&lt;table tabindex="2" class="autosuggest-results"&gt;&lt;/table&gt;&lt;/div&gt;&lt;input type="submit" id="symbol_ok" value="OK" name="s_ok" onclick="this.form.btn.value=this.name;this.form.symbol.value=this.form.symbol_entry.value; this.form.submit();"&gt;&lt;select id="dropdown-element" style="cursor:pointer" onchange="javascript:location.href=this.value;" data-cip-id="cIPJQ342845640"&gt;&lt;option selected="" style="display:none"&gt;Agregar a...&lt;/option&gt;&lt;option value="https://mx.advfn.com/common/alerts/newsalerts/add?symbol_search=BMV%3AHOMEX%2A&amp;amp;u=niino4879"&gt;Agregar Alarma de Noticias&lt;/option&gt;&lt;option value="https://mx.advfn.com/p.php?pid=alerts_edit&amp;amp;newsymbol=BMV%3AHOMEX%2A"&gt;Agregar Alarma de Precio&lt;/option&gt;&lt;option disabled="" value=""&gt;Agregar al Monitor:&lt;/option&gt;&lt;option value="https://mx.advfn.com/p.php?pid=mon&amp;amp;symbol_search=BMV%3AHOMEX%2A&amp;amp;mid=1"&gt; - Monitor Predeterminado&lt;/option&gt;&lt;option value="https://mx.advfn.com/p.php?pid=pf_add&amp;amp;from=pf"&gt;Crear un Portafolio&lt;/option&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="sub-menu" class="Element LinkListElement TabMenuElement "&gt;&lt;ul&gt;&lt;li class="odd first"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/historico"&gt;Resumen&lt;/a&gt;&lt;/li&gt;&lt;li class="even selected"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/historico/descargar"&gt;Descargar Histórico de Datos&lt;/a&gt;&lt;/li&gt;&lt;li class="odd last"&gt;&lt;a href="/bolsa-de-valores/BMV/homex-HOMEX*/historico/more-datos-historicos"&gt;Mas Datos Históricos&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;
  
  &lt;div align="center"&gt;&lt;table style="background-color: #ffffff;" cellspacing="1" cellpadding="2"&gt;&lt;tbody&gt;&lt;tr bgcolor="#6566a3"&gt;&lt;td colspan="3" align="center" class="mb title"&gt;&lt;font color="white"&gt;Descarga de Datos para BMV:HOMEX*&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr bgcolor="#f0f0E7"&gt;&lt;td class="m"&gt;&amp;nbsp;Datos diarios&lt;/td&gt;&lt;td class="m"&gt;&amp;nbsp;&lt;a href="https://mx.advfn.com/p.php?pid=data&amp;amp;daily=1&amp;amp;symbol=BMV%5EHOMEX%2A"&gt;CSV&lt;/a&gt;&lt;/td&gt;&lt;td class="m"&gt;&amp;nbsp;&lt;a href="https://mx.advfn.com/p.php?pid=data&amp;amp;daily=1&amp;amp;columnheads=1&amp;amp;symbol=BMV%5EHOMEX%2A"&gt;CSV (con encabezado)&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr bgcolor="#e5e5f3"&gt;&lt;td class="m"&gt;&amp;nbsp;28 días de datos Intradía por minuto&lt;/td&gt;&lt;td class="m"&gt;&amp;nbsp;&lt;a href="https://mx.advfn.com/p.php?pid=data&amp;amp;daily=0&amp;amp;symbol=BMV%5EHOMEX%2A"&gt;CSV&lt;/a&gt;&lt;/td&gt;&lt;td class="m"&gt;&amp;nbsp;&lt;a href="https://mx.advfn.com/p.php?pid=data&amp;amp;daily=0&amp;amp;columnheads=1&amp;amp;symbol=BMV%5EHOMEX%2A"&gt;CSV (con encabezado)&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;
  &lt;/div&gt;&lt;div style="margin: 10px 0px; text-align: center"&gt;&lt;/div&gt;&lt;div style="height: 15px"&gt;&lt;/div&gt;&lt;div class="clear"&gt;&lt;/div&gt;&lt;div id="RecentStocksViewedElement" style="text-align:center;width:970px; position:relative; margin:auto;"&gt;   &lt;div style="width:970px;text-align:left;margin:auto;display:inline-block"&gt;&lt;table id="RecentHistoryTbl" cellpadding="0" cellspacing="0" style=" float:left;border:1px solid #989898;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;width:970px; -moz-box-shadow: 0px 0px 2px #888;-webkit-box-shadow: 0px 0px 2px #888;box-shadow: 0px 0px 3px #888;clear:both;background-color:white;"&gt;
                  &lt;tbody&gt;&lt;tr&gt;&lt;td style="width:57px;"&gt;&lt;/td&gt;
                  &lt;td style="font-size:medium;font-family:arial, helvetica,sans-serif;font-weight:bold;text-align:left;height:30px;color:#3F3F3F;white-space: nowrap;"&gt;Su Consulta Reciente
                  &lt;/td&gt;
                  &lt;td id="history_pagination" style="font-size:small;color:grey;font-family:arial, helvetica,sans-serif;text-align:right;white-space: nowrap;"&gt;Página 1 de 2
                  &lt;/td&gt;
                  &lt;td style="width:57px;"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding-top:20px;"&gt;&lt;center&gt;&lt;a href="#"&gt;&lt;img id="left-arrow" src="/common/instrumentsHistory/images/hist-arrow-left.gif"&gt;&lt;/a&gt;&lt;/center&gt;&lt;/td&gt;&lt;td colspan="2"&gt;&lt;div id="slider" style="position: relative; width: 856px; overflow: hidden; height: 219px;"&gt;
                  &lt;div id="slider-container" style="position: absolute; top: 0px; left: 0px; width: 1712px; height: 160px;"&gt;
                  &lt;div id="d1" style="position: absolute; top: 0px; left: 0px;width: 856px;height: 160px;"&gt;&lt;table cellpadding="0" cellspacing="3"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align:center; width:102px; background-image:url('/common/instrumentsHistory/images/hist-box-grey.jpg'); background-repeat:no-repeat;" valign="top"&gt;
      &lt;table cellpadding="0" cellspacing="0" border="0" style="width:102px;cursor: pointer;" onclick="window.location='https://mx.advfn.com/bolsa-de-valores/BMV/homex-HOMEX*/cotizacion';"&gt;
          &lt;tbody&gt;&lt;tr style="height:15px;"&gt;
              &lt;td style="text-align:center;"&gt;
                  &lt;div style="margin-left:auto;margin-right:auto;background-color:black;width:36px;height:15px;-moz-border-bottom-left-radius: 5px;-webkit-border-bottom-left-radius: 5px;border-bottom-left-radius: 5px;-moz-border-bottom-right-radius: 5px;-webkit-border-bottom-right-radius: 5px;border-bottom-right-radius: 5px;position:relative;"&gt;
                      &lt;span style="font-size:12px;font-family:arial, helvetica,sans-serif;color:white;font-weight:bold;height:15px;position:absolute;top:1px;left:0px;width:36px;"&gt;BMV&lt;/span&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Can you please advise the correct way to get authenticated and send the POST request and login to the website ?</p>
  
  <p>Thanks !!</p>