使用python绕过HTTP 403(Way around HTTP 403 with python)

系统教程 行业动态 更新时间:2024-06-14 17:04:02
使用python绕过HTTP 403(Way around HTTP 403 with python)

我正在制作一个程序,使用谷歌搜索,但我不能因为HTTP错误403是否有任何方法围绕它或任何我使用机械化浏览这里是我的代码

from mechanize import Browser inp = raw_input("Enter Word: ") Word = inp SEARCH_PAGE = "https://www.google.com/" browser = Browser() browser.open( SEARCH_PAGE ) browser.select_form( nr=0 ) browser['q'] = Word browser.submit()

这是错误消息

Traceback (most recent call last): File "C:\Python27\Project\Auth2.py", line 16, in <module> browser.submit() File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 541, in submit return self.open(self.click(*args, **kwds)) File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 203, in open return self._mech_open(url, data, timeout=timeout) File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 255, in _mech_open raise response httperror_seek_wrapper: HTTP Error 403: request disallowed by robots.txt

请帮助,谢谢

im makeing a program that uses google to search but i cant becuase of the HTTP error 403 is there any way around it or anything im using mechanize to browse here is my code

from mechanize import Browser inp = raw_input("Enter Word: ") Word = inp SEARCH_PAGE = "https://www.google.com/" browser = Browser() browser.open( SEARCH_PAGE ) browser.select_form( nr=0 ) browser['q'] = Word browser.submit()

here is the error message

Traceback (most recent call last): File "C:\Python27\Project\Auth2.py", line 16, in <module> browser.submit() File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 541, in submit return self.open(self.click(*args, **kwds)) File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 203, in open return self._mech_open(url, data, timeout=timeout) File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 255, in _mech_open raise response httperror_seek_wrapper: HTTP Error 403: request disallowed by robots.txt

please help and thank you

最满意答案

您可以告诉Mechanize忽略robots.txt文件:

browser.set_handle_robots(False)

You can tell Mechanize to ignore the robots.txt file:

browser.set_handle_robots(False)

更多推荐

本文发布于:2023-04-24 20:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/b60e797c21c543cd6a69fd94af767fba.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:python   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!