如何在Python请求模块中使用POST方法? (或者如何在Python Web方法中绕过414错误)

时间:2015-03-11 06:33:39

标签: python html http

我有以下代码:

import requests
password="xxxx"
username="sooo27x"
final_url = "http://targetmine.nibio.go.jp/enrich/analysis/enrichment?theme=Integrated+Pathway+Cluster&dataSet=&taxonId=10090&cutOff=1.00&useSymbol=true&list=Ssb,Eny2,Hsp90b1,Ube3a,Cry1,Prkaa1,Gm4024,Gm4024,Tm9sf2,Ddx5,Hspa8,Rbm26,Btf3,Ppp1cb,Ywhae,Wdr92,Zbtb1,Rc3h2,Hnrnpa2b1,Cnn3,Ccdc59,Minpp1,Gm21399,Shfm1,Gm21399,Mbtps2,Ly75,Pdcl3,Pphln1,Serpinb6b,Txndc9,Mapk1ip1l,Cox17,Psmb4,Seh1l,Mrpl11,Alas1,Mrpl52,Mrpl52,Mrpl52,Ssr3,Arcn1,Grb2,Ufm1,Manf,Nus1,LOC100505064,LOC100505064,Morf4l2,Nus1,Mmp19,Frzb,Slc39a1,Fus,Vma21,Ergic2,Hif1a,Gm13363,Odc1,Odc1,Ap1g1,Agfg1,Agfg1,Agfg1,Slc16a1,Ctps,Ak4,Orc4,Stat5a,Ube2d3,Gale,Sec61a1,Sar1a,Smc1a,Alkbh1,Arih2,Slc31a1,Lrrc59,Vmp1,Id2,Ppp2r3d,Wipf2,Chd1,Piga,Foxp3,Trak1,Snf8,Ctsz,Efhd2,Efhd2,Erp44,2810403A07Rik,Calr,Vamp3,Gm6747,Tmem30a,Rab1,Glis3,Chsy1,Ndufs4,Trim47,9430038I01Rik,Csnk2b,Hars,Grpel1,Psmd2,Uqcrc1,Sf3b2,Kdm1a,Rnps1,Zc3h10,Cnot7,Usp16,Hspa9,Rpl7l1,Srsf1,Uspl1,Sltm,Adnp2,Zfp451,Rbbp5,Cul4b,Smek1,Smad2,Cops3,Qrich1,Shq1,2310036O22Rik,Ngdn,Zcchc9,Eif4a1,Eif4a1,Ankrd28,Yrdc,Bzw1,Bzw1,Gmps,Rars,Zc3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apre1,Polr2m,Txnl4a,Mrpl38,Rrp7a,Ier3ip1,Senp2,Snrnp35,Bcl2l11,Mettl22,Ppie,C3ar1,C3ar1,C3ar1,Fgfbp3,Fcgr4,Neb,Cd70,Taf15,Igsf8,Pvr,Otud4,Apol7a,Tmcc3,Mrpl13,Mei4,Ddx6,Il12b,Il12b,Tmem39a,Fscn1,Fscn1,Ddx55,Pogk,Mcm9,Nudcd3,Adap1,Nfkbib,Tbc1d8,Relb,Suds3,Traf2,Il2ra,Traf1,LOC100653389,Gadd45b,Gadd45b,Pcdh19,Hk2,Ghitm,Rnf4,Cstf3,Tmem68,Ctage5,Fscn1,Nck2,Traf1,Aebp2,Rnf115,Rnf115,Cdh17,Amigo2,1500012F01Rik,Tubb2b,Fam129a,Fam89a,Rad51ap1,Rad51,Hells,Gins1&showBg=false"
r = requests.get(final_url,auth=(username,password))
print r.text

打印哪些:

In [33]: print r.text
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>414 Request-URI Too Large</title>
</head><body>
<h1>Request-URI Too Large</h1>
<p>The requested URL's length exceeds the capacity
limit for this server.<br />
</p>
<hr>
<address>Apache/2.2.15 (Scientific Linux) Server at sagace.nibio.go.jp Port 80</address>
</body></html>

请注意,它会输出414错误。我的问题是如何在Requests中使用POST方法来解决这个问题?除Requests之外的其他解决方案也欢迎。

1 个答案:

答案 0 :(得分:1)

使用requests.post()代替requests.get()并将参数移动到表单编码数据中。例如,不要在网址中使用theme=Integrated+Pathway+Cluster,而是执行

payload = {
     'theme': 'Integrated+Pathway+Cluster'
}
requests.post(final_url, data=payload)

(从网址中删除theme参数)。您可能会在URL中使用大量参数执行相同的过程,直到错误得到解决。