简体   繁体   English

Python 用于 web 抓取的程序的 Google 身份验证

[英]Python Google authentication for a program used for web scraping

Never done this but, I'm trying to build a program, that would scrape a google classroom site specific to the user that's logged in. Even when logged in the main browser google denies the request and instead gives me authentication error (I need to login in other words) how can I be logged in, in the program so that google accepts my request and grants me to scrape classroom sites.从来没有这样做过,但是,我正在尝试构建一个程序,它会抓取特定于已登录用户的谷歌课堂网站。即使在主浏览器中登录时,谷歌也会拒绝请求,而是给我身份验证错误(我需要换句话说,登录)我怎样才能在程序中登录,以便谷歌接受我的请求并允许我抓取课堂网站。

Tried this solution but without luck: Logging into Google using Python尝试过此解决方案但没有运气: 使用 Python 登录 Google

It was published a while ago and google could have changed the requirements for these kind of program authentication.它是在不久前发布的,谷歌本可以更改对此类程序身份验证的要求。

What I desire is to get into the section only available for me when I'm logged in, eg content of my classroom and grab some text from it, is it even possible?我想要的是进入仅在我登录后才可用的部分,例如我的课堂内容并从中获取一些文本,这甚至可能吗?

It would be expensive to try and implement a log-in mechanism, especially with all the 2FA requirements of Google solutions today.尝试实施登录机制的成本很高,尤其是在当今 Google 解决方案的所有 2FA 要求的情况下。

What would be quicker and usually works in software automation today is to have a manually logged in session and then start the browser with the user data directory pointed to it.在当今的软件自动化中,更快且通常有效的方法是手动登录 session,然后使用指向它的用户数据目录启动浏览器。 This is how it's usually achieved and the relogin is done manually from time to time, only when needed.这是通常实现的方式,并且仅在需要时才不时手动完成重新登录。 More info on how to set up a user data directory here .有关如何在此处设置用户数据目录的更多信息。

This gets you up and running pretty fast.这可以让您快速启动和运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM