【发布时间】:2017-08-01 18:31:00
【问题描述】:
我正在尝试使用 PyQt5 制作一个带有 GUI 的应用程序,它在 Instagram 上做它的事情。这是我坚持的一个功能:
def pro_smt(self):
url = "https://www.instagram.com/someonespicture123"
sauce = urllib.request.urlopen(url)
soup = bs.BeautifulSoup(sauce, 'lxml')
#I use this to check whether the profile is public, and therefore accessible without loggin in.
self.browserWindow.load(QUrl(url))
self.browserWindow.show()
问题是,如果我输入某人的 url,他们的帐户设置为仅向朋友显示他们的图片,我在 Python 中收到“404 not found”错误。 所以我必须以某种方式登录,才能访问这些类型的图像。
所以我的问题是如何从我的 Chrome 浏览器导入我的 Cookie,并将它们与请求一起发送,以便我登录,并且当然保持登录状态 - 这样我就可以在保持登录状态的同时使用 QWebEngineView 浏览页面并在没有失败的情况下执行 urllib.requests。
环境: Python 3.6.2、PyQt5.9、Windows10x64
【问题讨论】:
标签: python-3.x cookies beautifulsoup urllib pyqt5