日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python模拟登陆

發(fā)布時間:2023/12/15 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python模拟登陆 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

簡單使用python(python3.7)模擬登陸github

# !/usr/bin/env python # -*-coding:utf-8-*- """ @Author? : xiaofeng @Time? ? : 2018/12/18 16:31 @Desc : Less interests,More interest. (模擬登陸github) @Project : python_appliction @FileName: github.py @Software: PyCharm @Blog? ? :https://blog.csdn.net/zwx19921215 """import bs4 import requests# 聲明頭信息 headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0' }login_url = 'https://github.com/login' login_post = 'https://github.com/session' session = requests.session()""" 獲取authenticity_token """def get_token():response = session.get(url=login_url, headers=headers)soup = bs4.BeautifulSoup(response.text, 'html.parser')# xx = soup.find('input', {'id': 'xxx'}).get('value')token = soup.find('input', {'name': 'authenticity_token'}).get('value')print(token)return token""" 模擬登陸 """def sign_in(username, password):form_data = {'commit': 'Sign in','utf8': '?','authenticity_token': get_token(),'login': username,'password': password}response = session.post(url=login_post, data=form_data, headers=headers)if response.status_code == 200:print("congratulations login success ^_^")print(response.text)if __name__ == '__main__':sign_in('username', 'password')

?

總結(jié)

以上是生活随笔為你收集整理的python模拟登陆的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。