大家。我想在Github上使用python发送新问题,但是我不想使用github api。而且我正在接受422错误。也许我的方法有问题。我不知道 。你能帮助我吗。我是Python的新手。
import requests
from bs4 import BeautifulSoup
with requests.Session() as s:
url = "https://github.com/session"
r = s.get(url, headers=headers)
soup = BeautifulSoup(r.content, "lxml")
login_data['authenticity_token'] = soup.find("input", attrs={"name": "authenticity_token"})['value']
r = s.post(url, data=login_data, headers=headers)
url2 = "https://github.com/sadikizgi/dribbbleClonOnRails/issues"
r2 = s.get(url2)
soup2 = BeautifulSoup(r2.content, "lxml")
issue_data['authenticity_token'] = soup2.find("input", attrs={"name": "authenticity_token"})['value']
issue_data['timestamp'] = soup2.find("input", attrs={"name": "timestamp"})['value']
issue_data['timestamp_secret'] = soup2.find("input", attrs={"name": "timestamp_secret"})['value']
r2 = s.post(url2, data=issue_data, headers=headers)
print(issue_data)
print(r2.status_code)