python - 使用访问代码 (APS) 打开 URL 的 Python 脚本
问题描述
我正在尝试在 python 中编写一个脚本来访问以下页面的内容:
https://authors.aps.org/Submissions/status/
到目前为止,我尝试的是通过以下方式使用 urllib.urlopen:
import urllib
access_code = 'XXXXXXX'
author = 'xxxxxxx'
url = 'https://authors.aps.org/Submissions/status/'
login_data = {
'accode':access_code,
'author':author,
'submit':'Submit'
}
login_data = urllib.parse.urlencode(login_data).encode('utf-8')
urllib.request.urlopen(url, login_data)
但我总是得到
HTTP Error 404: Not Found
你有什么建议吗?
非常感谢!
解决方案
你可能想要这样的东西:
import urllib.request
import urllib.parse
access_code = 'XXXXXXX'
author = 'xxxxxxx'
login_data = urllib.parse.urlencode({
'accode': access_code,
'author': author
})
url = 'https://authors.aps.org/Submissions/status?utf8=%E2%9C%93&commit=Submit&{login_data}'.format(login_data=login_data)
with urllib.request.urlopen(url) as f:
print(f.read().decode('utf-8'))
推荐阅读
- android - 上传到 Google Play 后,我可以删除我的 pepk 文件吗?
- azure-maps - Azure Maps - 如何将地图线图层置于编辑模式?
- css - 使用标题和列表改进 css 文本动画
- java - 无法在 tlogrow 中使用 restAPI 调用来规范化结果
- c++ - 如何使用大矢量大小进行排序?
- php - 在基于 Android 和 iOS 的智能手机上显示来自 EMBED HTML 标记的 PDF 文件失败
- java - 如何在java中继续收听输入流
- bluetooth - 我们可以使用蓝牙功能启用两个智能手表配对吗?
- python - 安装公共 python 包时避免使用私有辅助 pypi 存储库的密码
- vba - VBA webscraper 因意外原因停止工作