[selenium] selenium 과 requests 로그 인의 차이

2627 단어 SeleniumPython
로그 인 요청
import requests
import time
t = int(time.time()*1000)
#       
s = requests.Session()
post_url = 'http://account.chinaunix.net/login/login'
data = {
    'username': 'xxxxxxxxx',
    'password': 'xxxxxxxxx',
    '_token': 'nmSXhgHib8dTIC9DrATSkTzBBo4zz9eqDEPeG5i1',
    '_t': t
}
r = s.post(url=post_url, data=data,allow_redirects=False)
r = s.get('http://bbs.chinaunix.net/')
with open('chinaunix.html', 'w') as fp:
    fp.write(r.text)

selenium 로그 인
from selenium import webdriver
import  time
url = 'http://bbs.chinaunix.net/member.php?mod=logging&action=login&logsubmit=yes'

webdriver = webdriver.Chrome()


webdriver.get(url=url)

time.sleep(15)


webdriver.find_element_by_name('username').send_keys('xxxxxxxxx')

webdriver.find_element_by_name('password').send_keys('xxxxxxxxx')

webdriver.find_element_by_name('loginsubmit').click()

time.sleep(15)

with open('chinaunixselenium.html','w',encoding='utf-8') as fp:
    fp.write(webdriver.page_source)

Selenium 을 사용 하려 면 설치 해 야 합 니 다: pip install selenium 다운로드:http://chromedriver.storage.googleapis.com/index.html
         chromedriver       ,   :

------------2019        -----------
 

  :  chromeV74   driver         ,                 

ChromeDriver 78.0.3904.11 (2019-09-12)---------Supports Chrome version 78
ChromeDriver 77.0.3865.40 (2019-08-20)---------Supports Chrome version 77
ChromeDriver 76.0.3809.12 (2019-06-07)---------Supports Chrome version 76
ChromeDriver 75.0.3770.8 (2019-04-29)---------Supports Chrome version 75
ChromeDriver v74.0.3729.6 (2019-03-14)--------Supports Chrome v74
ChromeDriver v2.46 (2019-02-01)----------Supports Chrome v71-73
--------   2018        -------

ChromeDriver v2.45 (2018-12-10)----------Supports Chrome v70-72
ChromeDriver v2.44 (2018-11-19)----------Supports Chrome v69-71
ChromeDriver v2.43 (2018-10-16)----------Supports Chrome v69-71
ChromeDriver v2.42 (2018-09-13)----------Supports Chrome v68-70
ChromeDriver v2.41 (2018-07-27)----------Supports Chrome v67-69
ChromeDriver v2.40 (2018-06-07)----------Supports Chrome v66-68
ChromeDriver v2.39 (2018-05-30)----------Supports Chrome v66-68
ChromeDriver v2.38 (2018-04-17)----------Supports Chrome v65-67
ChromeDriver v2.37 (2018-03-16)----------Supports Chrome v64-66
ChromeDriver v2.36 (2018-03-02)----------Supports Chrome v63-65
ChromeDriver v2.35 (2018-01-10)----------Supports Chrome v62-64
 
 

좋은 웹페이지 즐겨찾기