website에 로그인하려고합니다. 다음 코드를 사용하십시오.Python이 ConnectionError를 요청합니다.
import requests
values = {'password': 'somepass', 'username': 'someusername'}
login_url = "http://voobly.com/login"
session_requests = requests.session()
r = session_requests.post(login_url, data=values,
headers=dict(referer=login_url))
그리고이 양식으로 웹 사이트에 로그인 할 수 있습니다.
HTTPConnectionPool(host='www.voobly.com', port=80): Max retries exceeded with url: /login
(Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f7cca037be0>:
Failed to establish a new connection: [Errno -2] Name or service not known',))
내가이 문제를 해결 수있는 방법 : 내가 코드를 실행할 때
<form action="/login/auth" method="post">
<label for="username">Username: </label>
<input type="text" name="username" id="username" class="inputfield" value="">
<label for="password">Password: </label>
<input type="password" name="password" id="password" class="inputfield">
<input type="submit" value="Login" class="login-button">
</form>
글쎄, 나는이 오류가? 브라우저에 로그인 할 수 있지만 파이썬 코드를 통해 로그인 할 수는 없습니다. 당신은 잘못된 URL에 POST 요청을 보내는
당신은 mechanize' 또는'selenium' – AlexDotis
'로 시도 할 수 있습니다 내가 너무 많이로 대답을 제거 요청과 관련이있다. –
기계화로 전환하는 것이 좋습니다. 기계화는 파이썬 2에서만 작동합니다. 파이썬 3에서 작업하고 있습니다. 셀레늄으로 시도해야합니까? – cactus