Skip to Content.
Sympa Menu

byte-of-python - [Byte-of-Python] problem in reading HTTPS page email links

byte-of-python AT lists.ibiblio.org

Subject: Discussion regarding the book 'A Byte of Python'

List archive

Chronological Thread  
  • From: "Shivayogimath D." <shivayogimath_d AT mindtree.com>
  • To: <byte-of-python AT lists.ibiblio.org>
  • Subject: [Byte-of-Python] problem in reading HTTPS page email links
  • Date: Tue, 8 Nov 2005 18:21:33 +0530

 

Hi Everybody,

 

Am trying to read a email ids which will be in the form of links ( on which if we click, they will redirect to outlook with their respective email ids).

And these links are in the HTTPS page, a secured http page.

The point is that am able to read some links with HTTP page, but am not able to read the same when I try with HTTPS.

 

Using the following code from sgmllib am able to read the links,

 

 

class MyParser(sgmllib.SGMLParser):

    def __init__(self):

        sgmllib.SGMLParser.__init__(self)

        self.inside_a = False

        self.address = ''

    def start_a(self,attrs):

        if DEBUG:

            print "start_a"

            print attrs

        for attr,value in attrs:

            if attr == 'href' and value.startswith('mailto:'):

                self.address = value[7:]

        self.inside_a = True

    def end_a(self):

        if DEBUG:

            print "end_a"

        if self.address:

            print '"%s" <%s>' % (self.nickname, self.address)

            mailIdList.append(self.address)

           

        self.inside_a = False

        self.address = self.nickname = ''

    def handle_data(self,data):

        if self.inside_a:

            self.nickname = data

 

 

And for the proxy authentication and the https handler am using the following lines of code

 

 

            authinfo = urllib2.HTTPBasicAuthHandler()

 

            proxy_support = urllib2.ProxyHandler ({"http" : "http://user:password@proxyname:port"})

 

            opener = urllib2.build_opener(proxy_support, authinfo, urllib2.HTTPSHandler)

 

            urllib2.install_opener(opener)

 

 

Then am trying to call the parser for the links in a particular https page which will be given as a command line argument. Which will read me all the links in that page.

 

p = MyParser()

for ln in urllib2.urlopen( sys.argv[1] ):

    p.feed(ln)

p.close()

 

 

NOTE : I have installed python with _ssl support also.

 

 

So with this code am able to read the links with HTTP page but not for the HTTPS page.

AM NOT GETTING ANY ERRORS EITHER BUT ITS NOT READING THE LINKS, THAT ARE PRESENT IN THE GIVEN HTTPS PAGE

 

Could you please tell me am I doing some thing wrong in the above code for any of the handlers.

 

 

I have got struck here from so many days, please give me the solution for this.

 

Thanks and regards

YOGI

 

-----------------------------------------------------------------------------------------------------------------------------
Disclaimer
-----------------------------------------------------------------------------------------------------------------------------

"This message(including attachment if any)is confidential and may be
privileged.Before opening attachments please check them
for viruses and defects.MindTree Consulting Private Limited (MindTree)will
not be responsible for any viruses or defects or
any forwarded attachments emanating either from within MindTree or outside.If
you have received this message by mistake please notify the sender by return
e-mail and delete this message from your system. Any unauthorized use or
dissemination of this message in whole or in part is strictly prohibited.
Please note that e-mails are susceptible to change and MindTree shall not be
liable for any improper, untimely or incomplete transmission."

-----------------------------------------------------------------------------------------------------------------------------

  • [Byte-of-Python] problem in reading HTTPS page email links, Shivayogimath D., 11/08/2005

Archive powered by MHonArc 2.6.24.

Top of Page