2016-09-29 124 views
0

我有一些無法登錄到這個網站:https://illinoisjoblink.illinois.gov/ada/r/home登錄網站與Python要求

我能夠提交有效載荷,但我重定向到自稱書籤錯誤的頁面。這裏是代碼和相關的錯誤消息。我不知道如何繼續。我感謝任何和所有的幫助。謝謝!

session = requests.Session() 
    soup = BeautifulSoup(session.get(SEARCH_URL).content, "html.parser") 
    inputs = soup.find_all('input') 
    token = '' 
    for t in inputs: 
     try: 
      if t['name'] == 'authenticity_token': 
       token = t['value'] 
       break 
     except KeyError as e: 
      pass 
    login_data = dict(v_username=USER_NAME, 
         v_password=PASSWORD, 
         authenticity_token=token, 
         commit='Log In') 
    login_data['utf-8'] = '✓' 

    r = session.post(LOGIN_URL, data=login_data) 

    print(r.content) 

Bookmark Error <b>You may be seeing this error as a result of bookmarking this page. Unfortunately, our site design will not allow the bookmarking of most internal pages.</b> If you wish to contact the system administra tor concerning this error, you may send an email to <a href="mailto:[email protected]">[email protected]</a>. Please reference error number <b>646389</b>.<p>Thank you for your patience.<br><br> Hit your browser back button to return to the previous page.

回答

0

也許你login_data參數是錯誤的?當我檢查POST登錄時,必要的參數看起來是:v_username,v_password,FormName,fromlogin,也許最重要的是,button。我建議你將所有這些參數添加到你的login_data字典中。你的字典看起來像這樣:

login_data = {'v_username': USER_NAME, 
       'v_password': PASSWORD, 
       'authenticity_token': token, 
       'FormName': 0, 
       'fromlogin': 1, 
       'button': 'Log+in'} 
+0

謝謝你的迴應。我將這些參數包含在我的字典中,但似乎沒有幫助。但是,當我擺脫'login_data ['utf-8'] ='&#x2713;'登錄根本不起作用,並且我被重定向到原始登錄頁面。另外,當我檢查POST登錄時,我沒有看到'FormName',''fromlogin'和'button'的位置。 – MvTvP