簡體   English   中英

使用python登錄網頁並在瀏覽器中顯示結果

[英]login a webpage using python and display the result in the browser

我是python的初學者,作為一個學習項目,我決定只制作一個小腳本吃午餐並登錄它。 現在,經過大量的谷歌搜索(獲得了很多混亂和知識),我發現每個網站都有其處理登錄請求的方式,並且有很多方法可以模擬瀏覽器實例來檢索和發布數據( urllib2,硒,斜紋和blablabla)。

因此,我知道可以從python登錄到網站(針對特定站點並使用特定方式),但是我似乎無法在瀏覽器中顯示登錄的頁面。

有人可以幫我嗎?

我認為硒可以做到這一點。

代碼段:

from selenium import webdriver 
from selenium.common.exceptions import NoSuchElementException 
from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox() # Get local session of firefox 
browser.get(yoursite) # Load page 
elem = browser.find_element_by_name("email") # Find the query box 
elem.send_keys(email) 

ps = browser.find_element_by_name("password") # Find the query box 
ps.send_keys(passwd + Keys.RETURN)

這段代碼將驅動您的Firefox打開打開的頁面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM