2014-04-23 13 views
-1

J'ai rencontré un problème qui consiste à utiliser Python pour se connecter à un site Web. Cependant, le login du site est une fenêtre qui sort, donc je ne sais pas comment utiliser Python pour mettre mes informations de connexion. Donc, mon but est de télécharger certaines données du site Web qui nécessite une connexion en premier. Auparavant, la page principale a une zone fixe pour les entrées, donc j'ai utilisé des demandes, et de la belle soupe. Maintenant, le journal en devient une fenêtre pop-out qui a besoin d'un "onclick" dans son code source ..Comment utiliser Python pour se connecter à un site Web avec une fenêtre surgissante

Précédent sol .:

import requests, pandas as pd 
import win32com.client 
import datetime as date 
from bs4 import BeautifulSoup 

payload = { 
    'action': 'client_login/client_authorise.asp?action=login', 
    'companyName': XXX, 
    'username': XXX, 
    'password': XXX 
} 

with requests.Session() as s: 
    s.post('http://www.mywebsite.com/', data = payload) 
    raw_cape = s.get('http://www.mywebsite.com/the page has my data/') 

code source pour fenêtre de connexion:

<table class='btn' cellpadding='0' cellspacing='0' style='margin-top:5px;' onclick="_infx.baltic.login.dialog();"> 
         <tr> 
          <td class='l'><img src="/images/spacer.gif" alt='' style='width:6px;border:0px;'/></td> 
          <td class='m'>Login</td> 
          <td class='r'><img src="/images/spacer.gif" alt='' style='width:6px;border:0px;'/></td> 
         </tr> 
        </table> 

maintenant partie du code source (pas sûr si cela est utile):

<p style='font-size:12px;line-height:16px;margin-bottom:8px;margin-top:8px;padding-left:0px;padding-top:0px;padding-bottom:0px;width:535px;padding:6px;background-color:#eee;border-radius:4px;'><b>_domain</b> - Remembers your login domain preference.</p> 
        <p style='font-size:12px;line-height:16px;margin-bottom:8px;margin-top:8px;padding-left:0px;padding-top:0px;padding-bottom:0px;width:535px;padding:6px;background-color:#eee;border-radius:4px;'><b>_company_id</b> - Remembers your login company id.</p> 
        <p style='font-size:12px;line-height:16px;margin-bottom:8px;margin-top:8px;padding-left:0px;padding-top:0px;padding-bottom:0px;width:535px;padding:6px;background-color:#eee;border-radius:4px;'><b>_company_name</b> - Remembers your login company name.</p> 
        <p style='font-size:12px;line-height:16px;margin-bottom:8px;margin-top:8px;padding-left:0px;padding-top:0px;padding-bottom:0px;width:535px;padding:6px;background-color:#eee;border-radius:4px;'><b>_username</b> - Remembers your login username.</p> 
+1

Cela va dépendre un peu sur la façon dont votre code est en interaction avec le site, et comment le site gère l'authentification. Pouvez-vous fournir plus d'informations sur la façon dont vous essayez de faire cela? – kyzen

+0

Merci pour votre réponse, j'ai édité mon poste pour montrer plus de détails .. Pls jeter un oeil .. – lsheng

Répondre

Questions connexes