Skip to content

Instantly share code, notes, and snippets.

@falsetru
Created June 10, 2013 09:05
Show Gist options
  • Save falsetru/5747416 to your computer and use it in GitHub Desktop.
Save falsetru/5747416 to your computer and use it in GitHub Desktop.
import lxml.html
import requests
FILENAME = '3.png'
r = requests.get('http://www.onlinebarcodereader.com/')
root = lxml.html.fromstring(r.text)
MAX_FILE_SIZE, = root.cssselect('input[name=MAX_FILE_SIZE]')
senderid, = root.cssselect('#senderid')
checksum, = root.cssselect('#checksum')
post_data = {
'MAX_FILE_SIZE': MAX_FILE_SIZE.get('value'),
'senderid': senderid.get('value'),
'checksum': checksum.get('value'),
}
print post_data
r = requests.post('http://www.onlinebarcodereader.com/', post_data, files={
'userfile': open(FILENAME, 'rb')
})
root = lxml.html.fromstring(r.text)
result, = root.cssselect('#result-raw')
print result.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment