-
-
Written by John Kosh John Kosh
-
Published: 08 September 2022 08 September 2022
The following is the standard setup for mechanize. the most current browser and window's OS/code]
[code]
import mechanize
# setting up the Mechanize browser headers
br = mechanize.Browser()
user_agent = [('user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27')]
#br.set_all_readonly(False) # allow everything to be written to
br.set_handle_robots(False) # ignore robots
br.set_handle_refresh(False) # can sometimes hang without this
br.addheaders = user_agent
url = 'https://johnkosh.com'
[/code]