[BangPypers] help needed to in Client Cookie module

suprabha ekka suprabha.ekka at gmail.com
Thu Sep 20 07:31:03 CEST 2012


I am providing the complete code ....

import urllib2
import urllib
import ClientCookie
import ClientForm
import sys
cj = ClientCookie.LWPCookieJar()
opener = ClientCookie.build_opener(urllib2.HTTPSHandler(),
ClientCookie.HTTPCookieProcessor(cj))
ClientCookie.install_opener(opener)
# input-type values from the html form
txtdata = {'userid':'asdcsearch.gen','password':'Asdc1234'}
data = urllib.urlencode(txtdata)

req3 = ClientCookie.Request("
https://cdx-stage.cisco.com/ecm/view/objectId/090dca388003e67c" ,data)
handle3 = ClientCookie.urlopen(req3)
content=handle3.read()
print content

https://cdx-stage.cisco.com/ecm/view/objectId/090dca388003e67c is a
download url ....So when i try downloading the url after providing the
authentication i will able to downlaod the content as ita simple text file.
But if it is a pdf or any other file it not able to downlaod the file.

Like take for example :-
https://cdx-stage.cisco.com/ecm/view/objectId/090dca388003e726 --> this a
doc file. And i am unable to get the content.

But for the download url :
https://cdx-stage.cisco.com/ecm/view/objectId/090dca388003e67c --> this is
a simple text file. I am able to get the content.
The content is
{"fileName":"s3223-ipservicesk9-mz.122-33.SRE4.bin","publishDate":"31-MAY-2011","featSetDesc":"IP
SERVICES
SSH","featInd":"Y","migrReleaseVersion":"","migrLifeCycle":"","minDram":"512","advisoryType":"SOFTWARE","featSetDescId":"1242","certificate":undefined,"migrSoftwareType":"","fileSize":"97811932","minFlash":"256","accessLevel":2,"advisoryUrl":"
http://www.cisco.com/web/software/DefTracker/280805679/SA/ac104828.html
","migrSoftwareConceptId":"","releaseFlag":"N","migrOperatingSystem":"","imageGuid":"7281E1D75D664CBFF5DECB3DEB426F1CA07ED989","fileDesc":"","migrRetirementDate":""}

The file other than the simple text file doesnt get downloaded.Thats the
issue.

i hope that is clear.

Thanks,
Suprabha





On Wed, Sep 19, 2012 at 9:00 PM, Ramchandra Apte <maniandram01 at gmail.com>wrote:

> On 19 September 2012 16:09, suprabha ekka <suprabha.ekka at gmail.com> wrote:
>
> > Hi ,
> >
> > I wanted to download a file from a content url . The content of the file
> is
> > pdf/doc/docx/.xls/ any ms supported file.
> > The simple text file i am able to download but i am unbal eto download
> any
> > other file.
> > The snippet of the code is :
> >
> > import urllib2
> > import urllib
> > import ClientCookie
> >
> > import sys
> > cj = ClientCookie.LWPCookieJar()
> > opener = ClientCookie.build_opener(urllib2.HTTPSHandler(),
> > ClientCookie.HTTPCookieProcessor(cj))
> > ClientCookie.install_opener(opener)
> > # input-type values from the html form
> > txtdata =
> {'userid':'****************','password':'**********************'}
> > data = urllib.urlencode(txtdata)
> >
> > req3 = ClientCookie.Request("**************************8" ,data)
> > handle3 = ClientCookie.urlopen(req3)
> > content=handle3.read()
> > print content
> >
> > Can any one tell me while i am able to download the content of simple
> text
> > file but why i am not abl to  download the ppt/pdf/ etc file. and how
> can i
> > do it.
> > Can anyone respond ASAP.
> >
> > Thanks in advance.
> >
> > -Suprabha
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> Please elobrate on the error (explain in more detail)
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list