mechanize (python) click on a javascript type link

后端 未结 2 740
逝去的感伤
逝去的感伤 2021-01-21 08:57

is it possible to have mechanize follow an anchor link that is of type javascript?

I am trying to login into a website in python using mechanize and beautifulsoup.

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-21 09:15

    You may set cookies using cookielib

    import mechanize
    import cookielib
    # add headers to your browser also
    browser = mechanize.Browser()
    browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
    cj = cookielib.LWPCookieJar()
    browser.set_cookiejar(cj)
    

    I doubt this is even relevant now, but oh well :)

提交回复
热议问题