Mechanize di python

from mechanize import Browser
browser = Browser() response = browser.open('http://www.google.com') print (response.code)

Hasil kode diatas:

Traceback (most recent call last):
  File "d:\Tutorial Python\10 - Project Saya\Non OOP\04_Mechanize.py", line 3, in <module>
    response = browser.open('http://www.google.com')
  File "C:\Users\acer\AppData\Local\Programs\Python\Python39\lib\site-packages\mechanize\_mechanize.py", line 257, in open
    return self._mech_open(url_or_request, data, timeout=timeout)
  File "C:\Users\acer\AppData\Local\Programs\Python\Python39\lib\site-packages\mechanize\_mechanize.py", line 313, in _mech_open
    raise response
mechanize._response.httperror_seek_wrapper: HTTP Error 403: b'request disallowed by robots.txt'
PS D:\Tutorial Python>


Dimana letak kesalahannya dan bagaimana supaya kode nya benar?
Saya masih belum paham betul tentang library mechanize di python.
Mohon dijawab ya teman teman

avatar AhmadXD

@AhmadXD

8 Kontribusi 2 Poin


Jawaban

kalau melihat errornyaย 
: HTTP Error 403: b'request disallowed by robots.txt'

mungkin dari websitenya sudah mencegah, tidak bisa dibuka via ini.
Coba website lain seperti github.com , etc...
avatar hilmanski

@hilmanski

2446 Kontribusi 2023 Poin


Login untuk gabung berdiskusi