Urllib: Encoding parameters cannot be separated from Urllib,urllib.urlencode,
Urllib.urlopen (Url,[,data])
Support post, differentiate post or get by parameter
URLLIB2: Send URL request to add HTTP request header field, but Add Cookie header field is invalid
Httplib: You can send a cookie field,
1 defGetread (page=1):2 3Url="http://cn.ae.aliexpress.com/wssellercrm/ajax_ws_seller_crm_list.htm"4Query_data=urllib.urlencode ({' by':'Tradetotalfund',5 'OrderType':'desc',6 'currentpage':'%s'%page7 })8 9headers={'Cookies':Ten 'acs_usuc_t=acs_rt=0552311d078047e49628c29bae7c5510; ali_apache_id=113.108.202.203.1411525480759.841347.4; Xman_us_t=x_lid=cn1501352204&sign=y&x_user=o8anv3hmlnvnclyplqx730tq76bwcdtoxl56lzqjuvk=&need_popup =y; xman_f=j/g6ytfi9zx/qpq2gkorwwstfoyc11nlaz5d2t0qchlpwriunnxyyssufp0tctsc0xzoc93b/lawdsexmbt/ s5owgpl0c2yhso1ze8wnbwshf0lqhxna07nalruawchr9jqjetgvkn2xf/mfgk690sztlspxkyk5kk2umkjn+ n96yd1p6h0j3dv1bpr01gzmniouvbdnpcdz+btwiu3zcapolwh4siz6eibznti48s6vs2ubzumk7dmyrk8yvgllu1k2ky7sxpfn9o+shenk/ ODLVKE+YRHWS4XQBUUW4RBRWQRMPJEGHENMMJFM74SD+IHYMHPTNHUQ2YVYEDRXGW2NRHEHTOXL; __utma=3375712.1054749006.1411533102.1411533102.1411533102.1; __utmc=3375712; __utmz=3375712.1411533102.1.1.utmcsr= (direct) |utmccn= (direct) |utmcmd= (none); aep_history=keywords%5e%0akeywords%09%0a%0aproduct_selloffer%5e%0aproduct_selloffer%092044496155; xman_t=q+lwz5g2za5zj5ym2wr4knga3sxe8ephlc1g87nvkawi3wpwpddgj9eljwqoglg4bdxj5a8e/ocayphlvoewaa15m+wl23ip+ 2hkc3bso/yjd0kpeebhfuuip6dihluogaxb7syfpb8ft+u59slhzxa/cux/ehiw0zybzp645cm/dmfuuv91sx48gnbw+5hxhti3zidje3vffa0jas4cj2db0mpq+ fcnxircgahqyzfvyx2q4djdvuxjzej8q6gynriprv638ywtcm+41tsaqewu8wqkeinzks1pkwy2of07vmoibq/ fn2gg27w12ywyfd0ferwtrhbg6g6+7ikkuzxqfdohuv+zzzupupvc4ol+drgdlmlkudundnkcj8d+0oyfnv0fqi4sdyb746irflro9grrkp95j /rbradjtuyodxecub7dc2l3awf1uqgxu81cdihxulxyd3xiiux0qthv4nq3b3aituvgvnsurl4rimk0gk7o4lsywa3n+ Ixhkj7izcpffbgr7umramrd1ybajs2gy7tl3pc6pqg0497lnzk6bp98z2voij1sajqk8wwtm4dsyxcb4tbpzmbfb+82qvau73j6dbc34pjlgbw /if6u+ra3rngldpsjwqh0gxeit6iri2zen0x9kxva2faiwpckvbvh6hw6f2opod8=; JSESSIONID=A003C292DF818CF827DCE0DB85DE80C0; ali_apache_track=mt=3|ms=|mid=cn1501352204; Ali_apache_tracktmp=w_signed=y; xman_us_f=x_l=1&x_locale=zh_cn&no_popup_today=n&x_user=cn| aveen| chow|cnfm|205829874&x_regin=cn&aep_site=glo&last_popup_time=1411525493024; INTL_LOCALE=ZH_CN; aep_usuc_f=region=cn&site=glo&c_tp=usd; intl_common_forever=0mbh06hlq3paqrc0fhvbhnfpgdeigm6rwfphuyozdnamahxkvgvqqa==; acs_t=qw7yrx/hyh7fy1xjei1ovey0qdtxxudiltrlu+Ap6iym+pgfaf/guj2wkkf7sizb ' One } AClient=httplib. Httpconnection ('cn.ae.aliexpress.com', 80) -Req_url="?". Join ('/wssellercrm/ajax_ws_seller_crm_list.htm', Query_data)) - PrintReq_url theClient.request ('GET', req_url,headers=headers) - -Response =Client.getresponse () - + PrintResponse.Status - PrintResponse.reason +Cont =Response.read () A #Print cont at returnReg.findall (cont)
View Code
URLLIB3: Can establish a connection pool, with post file function
Http=urllib3. Poolmanager ()
Res=http.request (' GET ', url,data)
Http=urllib3. Poolmanager ()
Res=http.request (' POST ', token_url,req_args,encode_multipart=false)
#如果请求响应报 Bad Request/bad content type information
Need to set parameter Encode_multipart=false
Urllib,urlib2 and HTTPLIB,URLLIB3