python - Mechanize HTTP Error 400: Bad Request what am I doing wrong -
i'm trying upload file specific webpage mechanize , let process file , download again. got no clue, why page still throwing 400 bad request error. set user-agent, accept headers, redirects, got no idea why isn't working.
my current code:
import mechanize import cookielib cj = cookielib.lwpcookiejar() br = mechanize.browser() br.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'), ('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'), ('accept-language', 'de,en-us;q=0.7,en;q=0.3'), ('accept-encoding', '')] br.set_handle_robots(false) br.set_cookiejar(cj) br.set_handle_equiv(true) br.set_handle_redirect(true) br.set_handle_referer(true) br.set_handle_robots(false) br.set_handle_refresh(mechanize._http.httprefreshprocessor(), max_time=1) filename = "spinner-metre.png" url = 'http://waifu2x.udp.jp/' br.open(url) br.select_form(nr=0) br.form.add_file(open(filename), 'text/plain', filename) br.form.set_value(['2'],name='noise') br.form.set_value(['2'],name='scale') br.submit() print br.read()
what doing wrong , how possibly fix this?
Comments
Post a Comment