# -*- coding: utf-8-*-
from lxml import etree
import urllib2
import urllib
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
hosturl ='***'
posturl = '***'
h = urllib2.urlopen(hosturl)
postData = {
'username' : '****',
'password' : '***',
'mod':'***',
'action':'***',
'_r':'***',
'inajax':'*',
'ajaxtarget':'****'
}
postData = urllib.urlencode(postData)
request = urllib2.Request(posturl, postData)
response = urllib2.urlopen(request)
detailurl= urllib2.urlopen('****')
menu = detailurl.read()
ress = etree.HTML(menu)
menudetail = ress.xpath('//select[@id="food_id"]/option/text()')
posturl2 = '****'
data = {
'flag':'0',
'class_id':'2',
'area_id':'1',
'saler_id':'19758',
'food_id':'146',
'add_date':'2016-12-26',
'food_num':'2',
'reason':''
}
cookies = '********'
HEADER = {
'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0',
'Cookie':cookies
}
postData2 = urllib.urlencode(data)
request = urllib2.Request(posturl2, postData2,headers=HEADER)
response = urllib2.urlopen(request)
print response.read()