我最近在 SO 的帮助下写了这篇文章。现在有人可以告诉我如何让它真正登录到板上吗?它以非登录格式显示所有内容。
import urllib2, re
import urllib, re
logindata = urllib.urlencode({'username': 'x', 'password': 'y'})
page = urllib2.urlopen("http://www.woarl.com/board/index.php", logindata)
pagesource = page.read()
print pagesource
最佳答案
最近有人问the same question you're asking .如果您通读该问题的答案,您将看到代码示例,向您展示如何仅使用标准库中的内容在 Python 脚本中浏览网站时保持登录状态。
已接受的答案可能不如 this other answer 对您有用,因为接受的答案处理涉及重定向的特定问题。但是,我建议您通读所有答案。
关于python - urllib2数据发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/321582/