python - 为什么当我尝试打开 Google AdWords 时,Python 中的 Machenize 包会打开支持页面?

标签 python python-2.7 url web-scraping google-ads-api

我使用 Machenize 打开 google AdWord 页面,但它重定向到支持页面,请参阅下面的代码:

br = mechanize.Browser()
br.set_handle_robots(False)  
br.set_handle_refresh(False)  

url="https://accounts.google.com/ServiceLogin"
br.open(url)
br.form = list(br.forms())[0]

email = "myEmail"
password = "myPassword"

br.form["Email"] = email 
br.form["Passwd"] = password

response=br.submit() # And submit ! so far its ok, now Im in right page

br.open("https://adwords.google.com/") # The problem is here, the browser doesnt open this page
print br.geturl() # It opens this page : https://support.google.com/adwords/answer/1704376?hl=en#browsersupport

我无法进入 AdWords 页面,登录后只能看到支持页面,为什么> 提前致谢。

最佳答案

当使用不受支持的浏览器时,AdWords 会重定向到此支持页面。

您应该能够通过伪造用户代理来解决此问题。

关于python - 为什么当我尝试打开 Google AdWords 时,Python 中的 Machenize 包会打开支持页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27913928/

相关文章:

Raspberry Pi 上的 Python 脚本在执行 mysql 语句时出现错误

python - 在命令行中终止python for循环程序而不关闭它?

python - 做字谜组的更好方法

PHP 总结任意 URL

python - CSV Python 序列错误

python - PyCharm 自动导入无法正确导入

python - 子进程 check_output(['dir' ]) 有利于 Linux 二进制文件

python - 仅存储不同的值 - Python 2.7 - re.search

angularjs - 如何检测第一个 "/"路由调用?

php - 创建随机 url 链接