Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 删除需要登录的中文网站时出错_Python_Web Scraping_Chinese Locale - Fatal编程技术网

Python 删除需要登录的中文网站时出错

Python 删除需要登录的中文网站时出错,python,web-scraping,chinese-locale,Python,Web Scraping,Chinese Locale,我不熟悉python和scraping,但需要从需要登录的中文数据库中获取信息。我在这里借鉴了很多技术,但似乎无法让我的脚本正确登录。谢谢你的帮助 登录页面中的html: #<input name="txtUserName" type="text" id="txtUserName" tabindex="1" class="input_txt" errortag="yzm-error" errorempty="请输入用户名">` #<input name="txtPassword

我不熟悉python和scraping,但需要从需要登录的中文数据库中获取信息。我在这里借鉴了很多技术,但似乎无法让我的脚本正确登录。谢谢你的帮助

登录页面中的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)