I am trying to submit text from a file to a form on a site with mechanize but the text doesn't look good there, if i copy-paste looks like this:
████
█⌡⌡⌡⌡████
█⌡⌡⌡⌡⌡⌡⌡⌡⌡█████
█⌡⌡⌡⌡⌡████⌡⌡⌡⌡⌡⌡████
█⌡⌡⌡██ ██⌡⌡⌡⌡⌡⌡⌡⌡█████
█⌡⌡⌡⌡█ █⌡⌡⌡⌡██⌡⌡⌡⌡⌡⌡⌡████
If i use the code Python looks like this:
����
���������
���������������
��������������������
������ ���������������
������ ������������������
����� ������ ���������������������
������������� �������� ���������������������������
Probably is something about encoding,can't make it work. In the original file,textfile.txt, encoding is OEM-US, i googled this and is cp437.
def functionaa(linksite, text):
import mechanize
import cookielib
# Browser
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(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)
edit = br.open(link)
html1 = edit.read()
br.select_form(nr=0)
br.form['textcode'] = "[pre]%s[/pre]" % text
br.submit()
f=open(r'E:\ABC\textfile.txt', 'r')
content = f.read()
functionaa("http://site.com", content)