我是python和抓取的新手,但是需要从需要登录的中文数据库中抓取信息。我从这里借用了许多技术,但似乎无法使我的脚本正确登录。感谢您的帮助!
登录页面中的html
:#<input name="txtUserName" type="text" id="txtUserName" tabindex="1" class="input_txt" errortag="yzm-error" errorempty="请输入用户名">`
#<input name="txtPassword" type="password" id="txtPassword" tabindex="2" class="input_txt" errortag="yzm-error" errorempty="请输入密码" autocomplete="false">
代码:
import requests
login_url = "http://mall.cnki.net/Login.aspx?p=http%3a%2f%2fmall.cnki.net%2findex.aspx"
request_url = "http://mall.cnki.net/reference/ref_readerItem.aspx?bid=&recid=R2008070580000085"
payload = {"txtUserName": "test112233", "txtPassword": "test135"}
with requests.Session() as session:
post = session.post(login_url, data=payload, verify=True)
r = session.get(request_url)
print(r.text)